Language Switching Implementation Guide
Language switching functionality is in the opensrp-client-core library.
The library has a sample of how the language switching works. Feel free to try it out first.
To implement language switching in your project:-
- Ensure the opensrp-client-core library is part of the project requirements
- Ensure each class in your app extends (directly or indirectly) a class in client-core. If it doesn't then extend MultiLanguageActivity instead of AppCompatActivity.
- Ensure your project does not have hard-coded strings. Put all strings in string resources.
- Ensure all the strings in string resources are translated as required in corresponding folders such as values-fr/strings.xml, values-ar/strings.xml
- To ensure activity titles are translated, set the titles programmatically e.g. setTitle(R.string.app_name);
Once a user selects a language in your project, save the language as shown below
Then refresh the current activity. See below example
Related articles
This site is no longer maintained. Please visit docs.opensrp.io for current documentation.