Building Apps with Jigx
Additional functionality

Localization

16min

 mobile app supports multiple languages, significantly enhancing its market presence, user engagement, and overall success by appealing to a broader and more diverse audience. The real power of the localization functionality lies in using a single that can have multiple translations associated with the , the app respects the language setting of the device and renders the in that language if the corresponding language file is found or defaults to English.

One jig in English & German
One jig in English & German


How it works

In every property that accepts string-based values, e.g., field labels, can be localized. Wherever TextLocale pops up in IntelliSense, the value can be localized. The localization to the TextLocal is specified in the Translation folder in a file for each language.

Only one translation file per language is used, For example, de.jigx for German will hold all the TextLocal id values for all s in the solution that must be localized.



IntelliSense for localized values
IntelliSense for localized values


In the under Profile>Settings>Language check that the setting Device is selected. This respects the settings of the device and if a matching language translation file is present in the solution the will show in that language.

Language Settings
Language Settings




Configuration

Configuring TextLocale is simple, and the translation can be:

  1. Static - Add localization to a using a unique identifier with translated text
  2. Dynamic - Add localization to a using ICU Message definitions

Static values - In the jig

  1. Invoke IntelliSense next to the property you want to translate.
  2. Select TextLocale
  3. Provide an id: for the value to be translated.
  4. Optional: add the defaultMessage: property with a value. If there is no translation found for the active device's language, it will either fallback to the specified defaultMessage or if one is not specified, to English.
jig.jigx


Static values - In the translation file

Once the unique id has been set for the TextLocale, the file containing the translation needs to be configured:

  1. In under the translations folder, create a new file. The file's name must be the ISO 6391-1 codes, for example, de.jigx for German, or fr.jigx for French.
  2. For multiple languages create a separate file per language required.
  3. Add the unique identifiers (id) values specified in the , with the corresponding translated text in the new file.
  4. If you using multiple languages, simply use the same unique identifiers (id) values in each language file and for static values ensure the translated text corresponds.
de.jigx
fr.jigx
cs.jigx


Dynamic values- In the jig

To set the TextLocal property dynamically

  1. Invoke IntelliSense next to the property you want to translate.
  2. Select TextLocale
  3. Provide an id: and values properties. The values property requires context variables that will be used in the translation file.
  4. Optional: add the defaultMessage: property with a value. If there is no translation found for the active device's language, it will either fallback to the specified defaultMessage or if one is not specified, to English.
jig.jigx


Dynamic values - In the translation file

Once the unique id has been set for the TextLocale, and the values configured the file containing the translation needs to be configured:

  1. For multiple languages create a separate file per language required.
  2. Add the unique identifiers (id) values specified in the , with the corresponding translated text in the new file.
  3. Add the context variable for the values specified in the . This can be values you add to the TextLocale: value option and ICU Message definitions.
  4. If you using multiple languages, simply use the same unique identifiers (id) values in each language file and for static values ensure the translated text corresponds.
localized-jig.jigx
de.jigx


Considerations for dynamic values

Dealing with spaces

  • The select clause is case-sensitive, avoid using spaces.
YAML

  • If your datasource has spaces you can add an entry for the translation variable that removes the space. In the code example below an entry translation_string has been added to facilitate spaces.
datasource
jig-component
translation-file

  • Be consistent when key names, for example, if you use underscore (_) then ensure all spaces are replaced with underscores.
  • Create a fallback for the variable. The fallback in the code example below is the other case. This means if the title variable is not cash_payment, the string Payment placeholder will be displayed.
fallback


Using conditions

  • When an expression or value of a property is configured with a condition, the condition needs to be defined in the translation file, see the code example below.
list.jigx
de.jigx (translation-file)


Examples and code snippets

The following examples with code snippets are provided:



Updated 03 Oct 2024
Doc contributor
Did this page help you?