| Start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Configuration types and qualifier names for each folder under the "res" directory Each resource directory under the Example of variations of `` directory with different qualifier values suffixed which are often seen in our android projects:
Exhaustive list of all different configuration types and their qualifier values for android resources:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Currency |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Adding translation to your Android app You have to create a different
strings.xml strings.xml(hi) Setting the language programmatically: The function above will change the text fields which are referenced from strings.xml. For example, assume that you have the following two text views: Then, after changing the locale, the language strings having the ids |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Type of resource directories under the "res" folder When localizing different types of resources are required, each of which has its own home in the android project structure.
Following are the different directories that we can place under the
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Change locale of android application programatically In above examples you understand how to localize resources of application. Following example explain how to change the application locale within application, not from device. In order to change Application locale only, you can use below locale util. Initialize locale that user preferred, from Application class. You also need to create a base activity and extend this activity to all other activity so that you can change locale of application only one place as follows : Note : Always initialize locale in constructor. Now you can use LocalizationActivity as follow. Note: When you change locale of application programmatically, need to restart your activity to take the effect of locale change In order to work properly for this solution you and use locale from shared preferences on app startup you `android:name=".LocaleApp"` in you Manifest.xml. Sometimes Lint checker prompt to create the release build. To solve such issue follow below options. First: If you want to disable translation for some strings only then add following attribute to default string.xml Second: Ignore all missing translation from resource file add following attribute It's the ignore attribute of the tools namespace in your strings file, as follows: Third: Another way to disable non-translatable string http://tools.android.com/recent/non-translatablestrings (opens new window) If you have a lot of resources that should not be translated, you can place them in a file named donottranslate.xml and lint will consider all of them non-translatable resources. Fourth: You can also add locale in resource file You can also disable missing translation check for lint from app/build.gradle |
Read Article
https://develop.horje.com/learn/1434/reference