class sap.ui.core.Locale

Control sample: sap.ui.core.Locale
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/core/Locale
Application Component: CA-UI5-COR

Locale represents a locale setting, consisting of a language, script, region, variants, extensions and private use section.


Constructor

Creates an instance of the Locale.

new sap.ui.core.Locale(sLocaleId)
Param Type Default Value Description
sLocaleId string

the locale identifier, in format en-US or en_US.


Methods Overview

Method Description
sap.ui.core.Locale.extend

Creates a new subclass of class sap.ui.core.Locale with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

sap.ui.core.Locale.fromSAPLogonLanguage

Retrieves a Locale for the given SAP logon language or BCP47 tag.

getExtension

Get the locale extension as a single string or null.

The extension always consists of a singleton character (not 'x'), a dash '-' and one or more extension token, each separated again with a dash.

Use #getExtensions to get the individual extension tokens as an array.

getExtensionSubtags

Get the locale extensions as an array of tokens.

The leading singleton and the separating dashes are not part of the result. If there is no extensions section in the locale tag, an empty array is returned.

getLanguage

Get the locale language.

Note that the case might differ from the original script tag (Lower case is enforced as recommended by BCP47/ISO639).

sap.ui.core.Locale.getMetadata

Returns a metadata object for class sap.ui.core.Locale.

getModernLanguage
getPreferredCalendarType
getPrivateUse

Get the locale private use section or null.

getPrivateUseSubtags

Get the locale private use section as an array of tokens.

The leading singleton and the separating dashes are not part of the result. If there is no private use section in the locale tag, an empty array is returned.

getRegion

Get the locale region or null if none was specified.

Note that the case might differ from the original script tag (Upper case is enforced as recommended by BCP47/ISO3166-1).

getSAPLogonLanguage

Best guess to get a proper SAP Logon Language for this locale.

Conversions taken into account:

  • use the language part only
  • convert old ISO639 codes to newer ones (e.g. 'iw' to 'he')
  • for Chinese, map 'Traditional Chinese' or region 'TW' to SAP proprietary code 'zf'
  • map private extensions x-saptrc, x-sappsd and saprigi to SAP pseudo languages '1Q', '2Q' and '3Q'
  • remove ext. language sub tags
  • convert to uppercase

Note that the conversion also returns a result for languages that are not supported by the default set of SAP languages. This method has no knowledge about the concrete languages of any given backend system.

Since 1.44 use {@link sap.ui.core.Configuration#getSAPLogonLanguage} instead as that class allows to configure an SAP Logon language.
getScript

Get the locale script or null if none was specified.

Note that the case might differ from the original language tag (Upper case first letter and lower case reminder enforced as recommended by BCP47/ISO15924)

getVariant

Get the locale variants as a single string or null.

Multiple variants are separated by a dash '-'.

getVariantSubtags

Get the locale variants as an array of individual variants.

The separating dashes are not part of the result. If there is no variant section in the locale tag, an empty array is returned.

toLanguageTag

sap.ui.core.Locale.extend

Creates a new subclass of class sap.ui.core.Locale with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

sap.ui.core.Locale.fromSAPLogonLanguage

Retrieves a Locale for the given SAP logon language or BCP47 tag.

Param Type DefaultValue Description
sSAPLogonLanguage string

A SAP logon language, e.g. "ZF" or a BCP47 language tag

getExtension

Get the locale extension as a single string or null.

The extension always consists of a singleton character (not 'x'), a dash '-' and one or more extension token, each separated again with a dash.

Use #getExtensions to get the individual extension tokens as an array.

getExtensionSubtags

Get the locale extensions as an array of tokens.

The leading singleton and the separating dashes are not part of the result. If there is no extensions section in the locale tag, an empty array is returned.

getLanguage

Get the locale language.

Note that the case might differ from the original script tag (Lower case is enforced as recommended by BCP47/ISO639).

sap.ui.core.Locale.getMetadata

Returns a metadata object for class sap.ui.core.Locale.

getModernLanguage

getPreferredCalendarType

getPrivateUse

Get the locale private use section or null.

getPrivateUseSubtags

Get the locale private use section as an array of tokens.

The leading singleton and the separating dashes are not part of the result. If there is no private use section in the locale tag, an empty array is returned.

getRegion

Get the locale region or null if none was specified.

Note that the case might differ from the original script tag (Upper case is enforced as recommended by BCP47/ISO3166-1).

getSAPLogonLanguage

Best guess to get a proper SAP Logon Language for this locale.

Conversions taken into account:

Note that the conversion also returns a result for languages that are not supported by the default set of SAP languages. This method has no knowledge about the concrete languages of any given backend system.

Since 1.44 use {@link sap.ui.core.Configuration#getSAPLogonLanguage} instead as that class allows to configure an SAP Logon language.

getScript

Get the locale script or null if none was specified.

Note that the case might differ from the original language tag (Upper case first letter and lower case reminder enforced as recommended by BCP47/ISO15924)

getVariant

Get the locale variants as a single string or null.

Multiple variants are separated by a dash '-'.

getVariantSubtags

Get the locale variants as an array of individual variants.

The separating dashes are not part of the result. If there is no variant section in the locale tag, an empty array is returned.

toLanguageTag