Simple implementation of Android platform in multiple languages
Here, we implement two languages: Simplified Chinese and Traditional Chinese.
Two folders are recommended in the res directory.
Values-zh-rCN
Values-zh-rTW
Both folders have a strings. xml file.
The IDS of two string tables with the same name are the same, but the content is in different languages.
For example, the <string name = "quit_dlg_title"> prompt </string>
<String name = "quit_dlg_content"> tired! Take a rest! Come back! </String>
<String name = "quit_dlg_okbtn_title"> good </string>
<String name = "quit_dlg_cacelbtn_title"> an error occurs. </string>
<String name = "quit_dlg_title"> prompt </string>
<String name = "quit_dlg_content"> tired! Take a rest! Remember it! </String>
<String name = "quit_dlg_okbtn_title"> good </string>
<String name = "quit_dlg_cacelbtn_title"> click here </string>
This is a string resource used for the dialog box.
At this time in the program
String strPackage = mContext. getApplication (). getPackageName (); Resources mRes = mContext. getResources (); int id = mRes. getIdentifier ("quit_dlg_title", "string", strPackage); // strTitle = mRes. getString (id );
In this way, the string is obtained. Instead
StrTitle = mRes. getString (R. string. quit_dlg_title );
In this way, you do not need to use it at the beginning of the code file.
Import the R file. Because once the package name of a normal method is changed, the Code must be changed.
Other strings are similar.
Programming of Android mobile phone software development language problems
1. the java language is the most important language for Android development, and most of the work is completed in java;
2. xml language, which is generally used for layout files and permission files of Android;
Android multi-language tangle
Android applications support multiple languages, including variants (dialects) of the same language. For example, in English,
En-rGB English
En-rUS American English
En-rCA Canadian English
...
If you want to translate these variants into different places, you can create multiple language resources and put them in the corresponding resource directory of the application source code. In this way, build the apk. After the installation, the application automatically selects the corresponding string Display Based on the language settings in the user's mobile phone.
/Res/values-en-rGB/strings. xml
/Res/values-en-rUS/strings. xml
/Res/values-en-rCA/strings. xml
Similarly, there are many variants in Spanish. You can determine which variants these customers use and store the corresponding translations in different directories.
Elasticsearch general Spanish (general)
Es-rAR Argentina Spanish
Es-rBO
Es-rCL
Es-rCO Columbia Spanish
Es-rCR
Es-rDO
Es-rEC
Es-rES Castile Spanish (Spanish for reading and writing)
Es-rGT
Es-rHN
Es-rMX Mexico Spanish
Es-rNI
Es-rPA
Es-powerpath
Es-rPR
Es-rPY
Es-fulfill
Es-rUS us Spanish
Es-rUY
Es-rVE
...