SAP UI5 - Localization

SAP UI5 supports localization concept based on Java platform.

Identifying the Language Code − For the identification of languages, the framework uses a language code of type string.

Resource Bundles − A resource bundle file is a Java properties file and contains key/value pairs where the values are language-dependent texts and the keys are language independent and used by the application to identify and access the corresponding values.

Resource bundles are a collection of *.properties files. All files are named with the same base name (prefix identifying the resource bundle), an optional suffix that identifies the language contained in each file, and the fixed .properties extension.

The language suffixes are formed according to the older JDK locale syntax. By convention, a file without a language suffix should exist and contain the raw untranslated texts in the developer's language. This file is used if no more suitable language can be found.

Resource bundle sap.ui.commons.message_bundle contains the following files −

  • − This file carries the raw text from the developer and it determines the set of keys.

  • − This file carries English text.

  • − This file carries text in American English.

  • − This file carries text in British English.

Use of Localized Texts in Applications

SAPUI5 provides two options to use localized texts in applications – the module and data binding.

The following code is used to get resource bundle for a given language −“”);
var oBundle ={url ; sUrl, locale:sLocale});

The following code is used to access the text in resource bundle −

Var sText = oBundle.getText(sKey);

The following code is used to get URL of a resource −

Var sUrl = sap.ui.resource(“sap.ui.table”,””);