Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Language switching functionality is in the opensrp-client-core library. To implement in your project, you have to ensure you have included the library.

The opensrp-client-core library has a sample of how the language switching works. Feel free to try it out first. 

...

  1. Ensure the opensrp-client-core library is part of the project requirements
  2. 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.
  3. Ensure your project does not have hard-coded strings. Put all strings in string resources. 
  4. Ensure all the strings in string resources are translated as required in corresponding folders such as values-fr/strings.xml, values-ar/strings.xml
  5. To ensure activity titles are translated, set the titles programmatically e.g. setTitle(R.string.app_name);
  6. Once a user selects a language in your project, save the language as shown below

    Info
    iconfalse
    LangUtils.saveLanguage(getApplicationContext(), LOCALE.getLanguage());

    Then refresh the current activity. See below example

    Info
    iconfalse
    Intent intent = new Intent(MainActivity.this, MainActivity.class);
    getApplicationContext().startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK));


Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@8e3d129a
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "Documentation"
labelskb-how-to-article

...