How to add a language to the setting language list of Android

Source: Internet
Author: User

Example:
After reading this, the android2.2 system has a Vietnamese font, so it supports Vietnamese. However, the language list in setting does not have the Vietnamese option. At first I went to localepicker. line 133 of the oncreate method of Java has been modified as follows:

  1. Mlocales = new loc [finalsize + 1];
  2. For (INT I = 0; I <finalsize; I ++ ){
  3. Mlocales [I] = preprocess [I];
  4. }
  5. Locale temp = new locale ("Vi", "VN"); // VI is Vietnamese
  6. Mlocales [finalsize] = new LOC (totitlecase (getdisplayname (temp), temp );
  7. Arrays. Sort (mlocales );

Copy code

After the language is re-compiled, the Vietnamese language is included in the language list, but the default English language is displayed after the click. That is to say, the system language has not been changed successfully, I have read the two attribute files about the language and the country in the/data/property/directory, both of which have been modified successfully. I will continue to follow the code, but I have not obtained the files yet. I Googled it, I found a post on android2.1 architecture parsing language customization (http://hi.baidu.com/gigatron/blo... c8ab20843bd0e24445d. If you are interested, check the language selection list in external/icu4c/stubdata/templates, after the change, the TXT file of the language configuration needs to be converted to dat. However, an error has been reported during the run icu_dat_generator.py 4.2 Command, which has not been completed yet. I hope that some friends who have been involved in this field will share their experiences, thank you. !
The problem has been solved. The solution step is written in the reply. Now, write it directly to this location:

First, modify the configuration file.
Location: build/target/product/languages_full.mk | languages_small.mk. The two files contain fragments such as product_locales: = en_us en_GB fr_fr it_it es_es es_us, in fact, the data source of the language selection list in setting comes from this. Since the source is found, we only need to add the language we want later, for example, to add Vietnamese text, you only need to add "vi_vn" to the back, but when you carefully open the two files for comparison, you will find a problem:
There is a snippet like product_locales: =, but the languages_small.mk language is less and smarter than the former. This is the answer. You can also find a full small, when we do not need more languages, the language in languages_small.mk can be satisfied, and the language is small, and the space occupied by the generated image will be relatively small, I have not verified it, but it is based on full in the same directory. comment "get a list of ages. we use the small list to save space on smaller devices. "speculative.
Well, next, there will be a question: Where can I set full or small? Just mentioned a full. MK file, which contains the following fragments: $ (call inherit-product, build/target/product/languages_small.mk). The path of the latter is what we want to set. Well, after the modification, it will take some time for the entire make, and many modules will be re-compiled.
Second: encoding method Modification
In Android, A listview will correspond to a data array, so we only need to add the required data in the array in the format. Our goal is com. android. settings. localepicker. java, make the following changes at the location of row 133 of the file:
Mlocales = new loc [finalsize + 1];
For (INT I = 0; I <finalsize; I ++ ){
Mlocales= Preprocess;
}
Locale temp = new locale ("Vi", "VN ");
Mlocales [finalsize] = new LOC (totitlecase (temp. getdisplaylanguage (temp), temp );
After this step, the setting language list contains Vietnamese, but after clicking Vietnamese, there is no change on the interface, because Android does not have an international resource file that responds to Vietnamese writing, you can write application tests on your own.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.