Localization

To reach the most users, your application should handle text in ways appropriate to the locales where your application will be used.

Providing Default resources

Whenever the application runs in a locale for which you have not provided locale-specific text, native devices will load the default strings from res/string/strings.xml.

If this default file is absent, or if it is missing a string that your application needs, then your application will not run and will show an error.

File structure:

res/
  string/
    strings.xml
<?xml version="1.0" encoding="utf-8"?>
<strings>
    <string name="TXT_HELLO_WORLD">Hello World !</string>
</strings>
TextLabel helloWorldLabel = new TextLabel(Res.string.TXT_HELLO_WORLD);

Providing Alternative resources

res/
  string/
    strings-en.xml
    strings-fr.xml

The alternative XML resource file can add new texts or override some of default texts.

Note

A best pratice is to define all possible texts keys inside the default strings.xml file.

Switching the default locale in the application

By default, strings are loaded with the current locale of the device (defined by the user inside the device parameters). In NeoMAD applications, you can override which locale to use for displaying texts.

ResManager.setLanguage(Res.lang.fr);