Class sap.ui.core.LocaleModule: sap/ui/core/Locale

extends Object

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

Constructor Summary
new sap.ui.core.Locale(sLocaleId)Creates an instance of the Locale.
Method Summary
sap.ui.core.Locale.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.Locale with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.core.Locale.getMetadata()Returns a metadata object for class sap.ui.core.Locale.
getExtension()Get the locale extension as a single string or null.
getExtensionSubtags()Get the locale extensions as an array of tokens.
getLanguage()Get the locale language.
getPrivateUse()Get the locale private use section or null.
getPrivateUseSubtags()Get the locale private use section
getRegion()Get the locale region or null if none was specified.
getSAPLogonLanguage()Best guess to get a proper SAP Logon Language for this locale.
getScript()Get the locale script or null if none was specified.
getVariant()Get the locale variants as a single string or null.
getVariantSubtags()Get the locale variants as an array of individual variants.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.core.Locale(sLocaleId)
Creates an instance of the Locale.
Parameters:
{string}sLocaleId the locale identifier, in format en-US or en_US.
Method Detail
sap.ui.core.Locale.extend(sClassName, oClassInfo?, FNMetaImpl?): function
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.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.core.Locale.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.Locale.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getExtension(): string
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.

Returns:
{string} the extension
getExtensionSubtags(): string[]
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.

Returns:
{string[]} the individual extension sections
getLanguage(): string
Get the locale language.

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

Returns:
{string} the language code
getPrivateUse(): string
Get the locale private use section or null.
Returns:
{string} the private use section
getPrivateUseSubtags(): string
Get the locale private use section
Returns:
{string} the private use section
getRegion(): string
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).

Returns:
{string} the ISO3166-1 region code (2-letter or 3-digits)
getSAPLogonLanguage(): string
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' to SAP proprietary code 'zf'
  • map private extensions x-sap1q and x-sap2q to SAP pseudo languages '1Q' and '2Q'
  • remove ext. language sub tags
  • convert to uppercase

Note: 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. It is therefore suggested to better use sap.ui.core.Configuration#getSAPLogonLanguage as that class at least allows to configure the SAP Logon language. From version 1.44 on, this method will be deprecated.

Since:
1.17.0
Returns:
{string} a language code that should
getScript(): string
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)

Returns:
{string} the script code or null
getVariant(): string
Get the locale variants as a single string or null.

Multiple variants are separated by a dash '-'.

Returns:
{string} the variant or null
getVariantSubtags(): string[]
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.

Returns:
{string[]} the individual variant sections