loio |
---|
91f21f176f4d1014b6dd926db0e91070 |
view on: demo kit nightly build | demo kit latest release
For the identification of languages, the framework uses a language code of type string
.
The language can be set via the language
parameter as described in Available Configuration Options.
If you need to provide the language as a parameter, we recommend using the
sap-ui-language
parameter.Besides
sap-ui-language
, also thesap-locale
andsap-language
parameters exist, which should only be used in the context of ABAP-based SAP application servers.
These OpenUI5 configuration options accept the following formats:
-
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. Examples are
de
,en-US
,zh-Hans-CN
. -
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. Examples are
de
,en_US
,zh_TW_Traditional
-
SAP proprietary language codes (only supported by URL parameter
sap-language
)OpenUI5 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 an OpenUI5 application is specified with the URL parameter
sap-language
, OpenUI5 assumes that it is an SAP proprietary language code and converts it to a BCP-47 language tag as follows:SAP Language Code
BCP 47 Language Tag
Description
ZH
zh-Hans
ZH
is the SAP language code for Simplified Chinese. The most generic representation in BCP 47 iszh-Hans
. Whilezh-CN
(Chinese, China) is another representation, SAPUI5 decided to usezh-Hans
.ZF
zh-Hant
ZF
is the SAP language code for Traditional Chinese. The most generic representation in BCP 47 iszh-Hant
. Whilezh-TW
(Chinese, Taiwan) is another representation, SAPUI5 decided to usezh-Hant
.SH
sr-Latn
SH
is the SAP language code for Serbian (Latin script).CT
cnr
CT
is the SAP language code for Montenegrin.6N
en-GB
6N
is the SAP language code for British English.1P
pt-PT
1P
is the SAP language code for Portuguese.1X
es-MX
1X
is the SAP language code for Mexican Spanish.3F
fr-CA
3F
is the SAP language code for Canadian French.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 displayed instead of the actual data. As no ISO639 code for this exists, the information has been added as a BCP 47 private extension to theen-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 extension's name).3Q
en-US-x-saprigi
3Q
is also used as a technical SAP language code in support scenarios and displays a pseudo translation ("rigi" in the private extension's name).Only these SAP-proprietary language codes are understood by OpenUI5. Other SAP-proprietary language codes are not automatically transformed. If you develop your app to run in the SAP Fiori launchpad, all other SAP-proprietary language codes are handled by the SAP Fiori launchpad.
If you don't make use of the SAP Fiori launchpad, you may have to explicitly implement the language handling. You can use the
sap/base/i18n/Localization.setLanguage()
method to provide both settings, a BCP 47 language code and the corresponding SAP-proprietary language, in one call. OpenUI5 will then use one of the two codes where appropriate (e.g. BCP 47 for the retrieval of translated texts or in HTTP Accept Headers, but the proprietary SAP language code when propagating thesap-language
URL parameter to an OData service).
OpenUI5 has the notion of a current language. It is determined during the OpenUI5 bootstrap from the following sources of information. The sources are ordered increasingly by priority and the last available user language/locale wins:
-
Hard-coded OpenUI5 default locale
en
-
Browser-derived language
-
sap-ui-language
configuration parameter (consider the order of the Available Configuration Options) -
sap-language
configuration parameter (consider the order of the Available Configuration Options) -
sap-locale
configuration parameter (consider the order of the Available Configuration Options) -
Locale configured in the application coding (for more information, see API Reference:
sap/base/i18n/Localization.setLanguage
. )sap.ui.require(["sap/base/i18n/Localization"], (Localization) => { // Change the language using the API Localization.setLanguage(...); // Retrieve the current language const sLanguage = Localization.getLanguage(); });
A call to the
Localization.setLanguage
. method does not guarantee that all already existing translatable texts will be adapted.The syntax of the value returned from
getLanguage
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 chosen the JDK-locale syntax.