android-Language Internationalization Reference
http://www.loc.gov/standards/iso639-2/php/code_list.php National language Tables
Overview
Internationalization (internationalization), aka i18n (because I
there are only 18 letters at the beginning and end of the word n
), there is also localization (localization), aka l10n (the same name) as the international counterpart.
The internationalization of the Android language is to display different languages depending on the region (set by the system).
Android Internationalization
Here we 中文
English
are internationalized with and between.
Set up the values folder for different countries
Because what we're doing here is internationalization between Chinese and English, so we've just created values-en
this directory, and that's values下的额strings.xml
our default language (loading this resource when the language of the system is not defined in the program's resources).
Start the layout
<?xmlVersion= "1.0" encoding= "Utf-8"?><linearlayoutxmlns:android="Http://schemas.android.com/apk/res/android"xmlns:tools="Http://schemas.android.com/tools"android:id="@+id/activity_main"android:layout_width="Match_parent"android:layout_height="Match_parent"android:orientation="Vertical"android:padding="10DP"tools:context="Little_david.internationalizationdemo.MainActivity"> <edittextandroid:layout_width="Match_parent"android:layout_height="Wrap_content"android:hint="User name"/> <edittextandroid:layout_width="Match_parent"android:layout_height="Wrap_content"android:hint="Password"/> <buttonandroid:layout_width="Match_parent"android:layout_height="Wrap_content"android:hint="Login"android:textallcaps="false"/></LinearLayout>
The cursor selects the hint
property and then presses the ALT+Entry
shortcut key, and then extracts all the strings in turn.
Revise Chinese as English
Edit vlaues-en/strings.xml
File
<!--This is the file before editing--<?xmlVersion= "1.0" encoding= "Utf-8"?><resources> <!--This is the name of our application and will not be automatically generated we need to add it manually-- <stringname="App_name">International Demo</string> <stringname="Login_username">User name</string> <stringname="Login_password">Password</string> <stringname="LOGIN_LOGIN_BTN">Login</string></resources><!--This is the modified file--<resources> <!--This is the name of our application and will not be automatically generated we need to add it manually-- <stringname="App_name">Internationalization Demo</string> <stringname="Login_username">Username</string> <stringname="Login_password">Password</string> <stringname="LOGIN_LOGIN_BTN">Login</string></resources>
Test effect
In Settings, modify the current language version to Chinese
Modify the current system language to English
Summarize
Manual internationalization too tired ah, we need to use Androidstudio plug-in to help us to operate internationally. The name of the plugin is AndroidLocalizationer
. How to use please Baidu.
android-language Internationalization