Show TOC

Identifying the Language Code / LocaleLocate this document in the navigation structure

For the identification of languages, the framework uses a language code of type string.

Currently, SAPUI5 accepts the following syntax forms:

  • The language codes according to the de facto standard BCP-47, which are used by most browsers for language identification. As of JDK 1.7 they are also supported by the Java locale class.

    Example: de, en-US, zh-Hans-CN

  • The Java Locale syntax that combines a lower case ISO 639 alpha-2 or alpha-3 language code with an ISO 3166 alpha-2 country code. Both codes are combined with an underscore. An arbitrary sequence of variant identifiers (also separated by underscores) can be appended as a third component.

    Example: de, en_US, zh_TW_Traditional

  • The SAP proprietary language codes. SAPUI5 applications are often used to connect to ABAP-based SAP application servers. These servers use SAP proprietary language codes for compatibility reasons. These language codes often match an ISO 639 alpha-2 language code, but not in all cases. If the language code for a SAPUI5 application is specified with the traditional URL parameter sap-language, SAPUI5 assumes that it is a SAP proprietary language code and converts it to a BCP-47 language tag as follows:

    SAP Language Code BCP47 Language Tag Description
    ZH zh-Hans ZH is the SAP language code for Simplified Chinese. The most generic representation in BCP47 is zh-Hans. zh-CN (Chinese, China) is another representation, but SAPUI5 decided to use zh-Hans.
    ZF zh-Hant ZF is the SAP language code for Traditional Chinese. The most generic representation in BCP47 is zh-Hant. zh-TW (Chinese, Taiwan) is another representation, but SAPUI5 decided to use zh-Hant.
    1Q en-US-x-saptrc 1Q is a technical SAP language code used in support scenarios, for example for translation issues. When you select this language code, the technical keys are display instead of the actual data. As no ISO639 code for this exists, the information has been added as a BCP47 private extension to the en-US language tag: "trc" stands for "trace" or "traceability".
    2Q en-US-x-sappsd 2Q is also used as a technical SAP language code in support scenarios and displays a pseudo translation ("psd" in the private extensions name).
Current Language Code / Locale

SAPUI5 has the notion of a current language. It is determined from the following sources of information. The sources are ordered increasingly by priority and the last available user language/locale wins:

  1. Hard-coded SAPUI5 default locale en

  2. Potentially configured browser language (window.navigator.browserLanguage); for Internet Explorer this is the language of the operating system

  3. Potentially configured user language (window.navigator.userLanguage); for Internet Explorer this is the language in the region settings

  4. General language information from the browser (window.navigator.language)

  5. Android: Language contained in the user agent string (window.navigator.userAgent)

  6. Locale configured in the application coding ( For more information, see the API Reference for sap.ui.core.Configuration in the Demo Kit.)

  7. Locale configured via URL parameters

You use the configuration API to retrieve the resulting current language as follows:

var sCurrentLocale = sap.ui.getCore().getConfiguration().getLanguage();
Note The syntax of the returned value depends on the syntax used for configuration. If the information source is one of the browser language properties, the returned language most likely is in BCP-47 format. If it is configured as a URL parameter, the user might have choosen the JDK Locale syntax.
Note None of the window.navigator.* properties in Internet Explorer (IE) reflect the settings of the Language Preference dialog. Instead, IE returns the language of the Operating System installation as browserLanguage and the language from the Operating System regional settings as userLanguage. As a result, the settings in the Language Preference dialog cannot be used for the current language of SAPUI5. This is often confusing for developers and a known shortcoming in IE. To circumvent this, an additional server request is required where IE provides the corresponding setting in theAccept-Language header. This server request, however, requires a backend component. SAPUI5 must be able to run without a server component and, thus, the server request is not implemented yet.