The Locale constructor is a standard built-in property of the Intl object.
The following algorithm refers to UTS 35's Unicode Language and Locale Identifiers grammar.
"language"
, "string"
, unicode_language_subtag
production, throw a "script"
, "string"
, unicode_script_subtag
, throw a "region"
, "string"
, unicode_region_subtag
, throw a unicode_locale_id
production.unicode_language_subtag
production of the unicode_language_id
replaced by the string language.unicode_script_subtag
production of the unicode_language_id
, thenunicode_language_subtag
production of the unicode_languge_id
of tag, "-"
, script, and the rest of tag.unicode_script_subtag
production of the unicode_language_id
replaced by the string script.unicode_region_subtag
production of the unicode_language_id
, thenunicode_language_subtag
production of the unicode_language_id
of tag, the substring corresponding to the "-" unicode_script_subtag
production of the unicode_language_id
if present, "-"
, region, and the rest of tag.unicode_region_subtag
production of the unicode_language_id
replaced by the string region.The following algorithm refers to UTS 35's Unicode Language and Locale Identifiers grammar.
unicode_locale_id
production.The UnicodeExtensionComponents abstract operation returns the attributes and keywords from extension, which must be a Unicode locale extension sequence. If an attribute or a keyword occurs multiple times in extension, only the first occurence is returned. The following steps are taken:
"-"
, k »)."-"
.The InsertUnicodeExtensionAndCanonicalize abstract operation inserts extension, which must be a Unicode locale extension sequence, into locale, which must be a String value with a structurally valid and canonicalized BCP 47 language tag. The following steps are taken:
The following algorithm refers to UTS 35's Unicode Language and Locale Identifiers grammar.
unicode_locale_id
production."-x-"
»).
The following algorithm refers to UTS 35's Unicode Language and Locale Identifiers grammar. When the
"kf"
, then"kn"
, then"calendar"
, "string"
, type
sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a "collation"
, "string"
, type
sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a "hourCycle"
, "string"
, « "h11"
, "h12"
, "h23"
, "h24"
», "caseFirst"
, "string"
, « "upper"
, "lower"
, "false"
», "numeric"
, "boolean"
, "numberingSystem"
, "string"
, type
sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a "kf"
, then"kn"
, thenThe Intl.Locale constructor has the following properties:
The value of
This property has the attributes { [[Writable]]:
The value of the [[RelevantExtensionKeys]] internal slot is « "ca"
, "co"
, "hc"
, "kf"
, "kn"
, "nu"
». If %Collator%.[[RelevantExtensionKeys]] does not contain "kf"
, then remove "kf"
from %Locale%.[[RelevantExtensionKeys]]. If %Collator%.[[RelevantExtensionKeys]] does not contain "kn"
, then remove "kn"
from %Locale%.[[RelevantExtensionKeys]].
The Intl.Locale prototype object is itself an ordinary object. %LocalePrototype% is not an Intl.Locale instance and does not have an [[InitializedLocale]] internal slot or any of the other internal slots of Intl.Locale instance objects.
The initial value of
The initial value of the @@toStringTag property is the string value "Intl.Locale"
.
This property has the attributes { [[Writable]]:
Intl.Locale.prototype.baseName
is an accessor property whose set accessor function is
unicode_language_id
production.
Intl.Locale.prototype.calendar
is an accessor property whose set accessor function is
This property only exists if %Locale%.[[RelevantExtensionKeys]] contains "kf"
.
Intl.Locale.prototype.caseFirst
is an accessor property whose set accessor function is
Intl.Locale.prototype.collation
is an accessor property whose set accessor function is
Intl.Locale.prototype.hourCycle
is an accessor property whose set accessor function is
This property only exists if %Locale%.[[RelevantExtensionKeys]] contains "kn"
.
Intl.Locale.prototype.numeric
is an accessor property whose set accessor function is
Intl.Locale.prototype.numberingSystem
is an accessor property whose set accessor function is
Intl.Locale.prototype.language
is an accessor property whose set accessor function is
unicode_locale_id
production.unicode_language_subtag
production of the unicode_language_id
.
Intl.Locale.prototype.script
is an accessor property whose set accessor function is
unicode_locale_id
production.unicode_language_id
production of locale does not contain the ["-" unicode_script_subtag]
sequence, return unicode_script_subtag
production of the unicode_language_id
.
Intl.Locale.prototype.region
is an accessor property whose set accessor function is
unicode_locale_id
production.unicode_language_id
production of locale does not contain the ["-" unicode_region_subtag]
sequence, return unicode_region_subtag
production of the unicode_language_id
.
The CanonicalizeLanguageTagCanonicalizeUnicodeLocaleId abstract operation returns the canonical and case-regularized form of the locale argument (which must be a String value that is a structurally valid Unicode BCP 47 Locale Identifier as verified by the A conforming implementation shall take the steps specified in the “BCP 47 Language Tag to Unicode BCP 47 Locale Identifier” algorithm, from Unicode Technical Standard #35 LDML § 3.3.1 BCP 47 Language Tag Conversion.
The following steps are taken:
"u"
."-"
to newExtension."-"
to newExtension."-"
to newExtension."u"
.The abstract operation CanonicalizeLocaleList takes the following steps:
"length"
)).
The ResolveLocale abstract operation compares a BCP 47 language priority list requestedLocales against the locales in availableLocales and determines the best available language to meet the request. availableLocales, requestedLocales, and relevantExtensionKeys must be provided as
The following steps are taken:
© 2020 Mozilla, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.