+

Search Tips   |   Advanced Search

Enforce language preference for MobileFirst messages

IBM MobileFirst Platform Foundation supports several languages, and based on the language of the device, appropriate translations are used to display system messages. However, we can enforce restriction to display messages only in a certain set of languages.

If the application supports only English and French, we can enforce a restriction so that IBM MobileFirst Platform Foundation displays the messages only in these languages.


Enforcing languages in hybrid and mobile web applications

We can provide a preferred list of languages to be used by MPF for translating system messages in application-descriptor.xml. The order of the languages is important and must be separated by comma.


Enforcing languages in native applications

We can provide a preferred list of languages in native environments by adding languagePreferences property in the appropriate client property file.


Fallback mechanism

The system compares the device locale with the values provided in the preference list. Here are the fallback mechanisms on how the system messages are displayed:

  1. If the device locale is available, the corresponding translation is used to display system messages.

  2. If the device locale (for example, fr-FR) is not in the preference list, or the locale is not supported by MPF, the device language (for example, fr) is used to compare with the values provided in preference list. If the language is available in the preference list, the corresponding translation is used to display system messages.

  3. If the device language (fr) is not in the preference list, or the language is not supported by MPF, the first language available in the list for translation is used.

The order of the languages specified in the preference list is important. We must list the order from generic to specific languages so that when the translation is not available, the generic language is loaded.

For the following example of the preference list, if the device language is set to German, MPF uses English to display the system messages. The reason is that de is not available in the list.


Parent topic: Develop globalized hybrid applications