%Intl% |
`Intl` |
diff --git a/spec/displaynames.html b/spec/displaynames.html
new file mode 100644
index 00000000..1e5a0046
--- /dev/null
+++ b/spec/displaynames.html
@@ -0,0 +1,263 @@
+
+
+ DisplayNames Objects
+
+
+ Abstract Operations for DisplayNames Objects
+
+
+ CanonicalCodeForDisplayNames ( _type_, _code_ )
+
+ The CanonicalCodeForDisplayNames abstract operation is called with arguments _type_, and _code_. It verifies that the _code_ argument represents a well-formed code according to the _type_ argument and returns the case-regularized form of the _code_. The algorithm refers to UTS 35's Unicode Language and Locale Identifiers grammar. The following steps are taken:
+
+
+ 1. If _type_ is *"language"*, then
+ 1. If _code_ does not match the `unicode_language_id` production, throw a *RangeError* exception.
+ 1. If IsStructurallyValidLanguageTag(_code_) is *false*, throw a *RangeError* exception.
+ 1. Set _code_ to CanonicalizeUnicodeLocaleId(_code_).
+ 1. Return _code_.
+ 1. If _type_ is *"region"*, then
+ 1. If _code_ does not match the `unicode_region_subtag` production, throw a *RangeError* exception.
+ 1. Let _code_ be the result of mapping _code_ to upper case as described in .
+ 1. Return _code_.
+ 1. If _type_ is *"script"*, then
+ 1. If _code_ does not match the `unicode_script_subtag` production, throw a *RangeError* exception.
+ 1. Let _code_ be the result of mapping the first character in _code_ to upper case, and mapping the second, third and fourth character in _code_ to lower case, as described in .
+ 1. Return _code_.
+ 1. Assert: _type_ is *"currency"*.
+ 1. If ! IsWellFormedCurrencyCode(_code_) is *false*, throw a *RangeError* exception.
+ 1. Let _code_ be the result of mapping _code_ to upper case as described in .
+ 1. Return _code_.
+
+
+
+
+
+ The Intl.DisplayNames Constructor
+
+
+ The DisplayNames constructor is a standard built-in property of the Intl object.
+
+
+
+ Intl.DisplayNames ( _locales_, _options_ )
+
+
+ When the *Intl.DisplayNames* function is called with arguments _locales_ and _options_, the following steps are taken:
+
+
+
+ 1. If NewTarget is *undefined*, throw a *TypeError* exception.
+ 1. Let _displayNames_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%DisplayNames.prototype%"*, « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
+ 1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
+ 1. Let _options_ be ? ToObject(_options_).
+ 1. Let _opt_ be a new Record.
+ 1. Let _localeData_ be %DisplayNames%.[[LocaleData]].
+ 1. Let _matcher_ be ? GetOption(_options_, *"localeMatcher"*, *"string"*, « *"lookup"*, *"best fit"* », *"best fit"*).
+ 1. Set _opt_.[[localeMatcher]] to _matcher_.
+ 1. Let _r_ be ResolveLocale(%DisplayNames%.[[AvailableLocales]], _requestedLocales_, _opt_, %DisplayNames%.[[RelevantExtensionKeys]]).
+ 1. Let _style_ be ? GetOption(_options_, *"style"*, *"string"*, « *"narrow"*, *"short"*, *"long"* », *"long"*).
+ 1. Set _displayNames_.[[Style]] to _style_.
+ 1. Let _type_ be ? GetOption(_options_, *"type"*, *"string"*, « *"language"*, *"region"*, *"script"*, *"currency"* », *undefined*).
+ 1. If _type_ is *undefined*, throw a *TypeError* exception.
+ 1. Set _displayNames_.[[Type]] to _type_.
+ 1. Let _fallback_ be ? GetOption(_options_, *"fallback"*, *"string"*, « *"code"*, *"none"* », *"code"*).
+ 1. Set _displayNames_.[[Fallback]] to _fallback_.
+ 1. Set _displayNames_.[[Locale]] to the value of _r_.[[Locale]].
+ 1. Let _dataLocale_ be _r_.[[dataLocale]].
+ 1. Let _dataLocaleData_ be _localeData_.[[<_dataLocale_>]].
+ 1. Let _types_ be _dataLocaleData_.[[types]].
+ 1. Assert: _types_ is a Record (see ).
+ 1. Let _typeFields_ be _types_.[[<_type_>]].
+ 1. Assert: _typeFields_ is a Record (see ).
+ 1. Let _styleFields_ be _typeFields_.[[<_style_>]].
+ 1. Assert: _styleFields_ is a Record (see ).
+ 1. Set _displayNames_.[[Fields]] to _styleFields_.
+ 1. Return _displayNames_.
+
+
+
+
+
+ Properties of the Intl.DisplayNames Constructor
+
+
+ The Intl.DisplayNames constructor has the following properties:
+
+
+
+ Intl.DisplayNames.prototype
+
+
+ The value of `Intl.DisplayNames.prototype` is *%DisplayNames.prototype%*.
+
+
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+
+
+ Intl.DisplayNames.supportedLocalesOf ( _locales_ [ , _options_ ] )
+
+
+ When the *supportedLocalesOf* method of *%DisplayNames%* is called, the following steps are taken:
+
+
+
+ 1. Let _availableLocales_ be *%DisplayNames%*.[[AvailableLocales]].
+ 1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
+ 1. Return ? SupportedLocales(_availableLocales_, _requestedLocales_, _options_).
+
+
+
+
+ Internal slots
+
+
+ The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in .
+
+
+
+ The value of the [[RelevantExtensionKeys]] internal slot is « ».
+
+
+
+ The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in and the following additional constraints:
+
+
+
+ - [[LocaleData]].[[<_locale_>]] must have a [[types]] field for all locale values _locale_. The value of this field must be a Record, which must have fields with the names of one of the valid display name types: *"language"*, *"region"*, *"script"*, and *"currency"*.
+ - The value of fields *"language"*, *"region"*, *"script"*, and *"currency"* must be a Records which must have fields with the names of one of the valid display name styles: *"narrow"*, *"short"*, and *"long"*.
+ - The display name styles fields under display name type *"language"* should contain Records, with keys corresponding to language codes according to `unicode_language_id` production. The value of these fields must be string values.
+ - The display name styles fields under display name type *"region"* should contain Records, with keys corresponding to region codes. The value of these fields must be string values.
+ - The display name styles fields under display name type *"script"* should contain Records, with keys corresponding to script codes. The value of these fields must be string values.
+ - The display name styles fields under display name type *"currency"* should contain Records, with keys corresponding to currency codes. The value of these fields must be string values.
+
+
+
+ It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at http://cldr.unicode.org/).
+
+
+
+
+
+ Properties of the Intl.DisplayNames Prototype Object
+
+
+ The Intl.DisplayNames prototype object is itself an ordinary object. %DisplayNames.prototype% is not an Intl.DisplayNames instance and does not have an [[InitializedDisplayNames]] internal slot or any of the other internal slots of Intl.DisplayNames instance objects.
+
+
+
+ Intl.DisplayNames.prototype.constructor
+
+
+ The initial value of *Intl.DisplayNames.prototype.constructor* is the intrinsic object *%DisplayNames%*.
+
+
+
+
+ Intl.DisplayNames.prototype[ @@toStringTag ]
+
+
+ The initial value of the @@toStringTag property is the string value *"Intl.DisplayNames"*.
+
+
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
+
+
+
+
+ Intl.DisplayNames.prototype.of ( _code_ )
+
+
+ When the *Intl.DisplayNames.prototype.of* is called with an argument _code_, the following steps are taken:
+
+
+
+ 1. Let _displayNames_ be *this* value.
+ 1. If Type(_displayNames_) is not Object, throw a *TypeError* exception.
+ 1. If _displayNames_ does not have an [[InitializedDisplayNames]] internal slot, throw a *TypeError* exception.
+ 1. Let _code_ be ? ToString(_code_).
+ 1. Let _code_ be ? CanonicalCodeForDisplayNames(_displayNames_.[[Type]], _code_).
+ 1. Let _fields_ be _displayNames_.[[Fields]].
+ 1. Let _name_ be _fields_[[<_code_>]].
+ 1. If _name_ is not *undefined*, return _name_.
+ 1. If _displayNames_.[[Fallback]] is *"code"*, return _code_.
+ 1. Return *undefined*.
+
+
+
+
+ Intl.DisplayNames.prototype.resolvedOptions ( )
+
+
+ This function provides access to the locale and options computed during initialization of the object.
+
+
+
+ 1. Let _displayNames_ be *this* value.
+ 1. If Type(_displayNames_) is not Object, throw a *TypeError* exception.
+ 1. If _displayNames_ does not have an [[InitializedDisplayNames]] internal slot, throw a *TypeError* exception.
+ 1. Let _options_ be ! ObjectCreate(%ObjectPrototype%).
+ 1. For each row of , except the header row, in table order, do
+ 1. Let _p_ be the Property value of the current row.
+ 1. Let _v_ be the value of _displayNames_'s internal slot whose name is the Internal Slot value of the current row.
+ 1. If _v_ is not *undefined*, then
+ 1. Perform ! CreateDataPropertyOrThrow(_options_, _p_, _v_).
+ 1. Return _options_.
+
+
+
+ Resolved Options of DisplayNames Instances
+
+
+
+ Internal Slot |
+ Property |
+
+
+
+ [[Locale]] |
+ *"locale"* |
+
+
+ [[Style]] |
+ *"style"* |
+
+
+ [[Type]] |
+ *"type"* |
+
+
+ [[Fallback]] |
+ *"fallback"* |
+
+
+
+
+
+
+
+ Properties of Intl.DisplayNames Instances
+
+
+ Intl.DisplayNames instances are ordinary objects that inherit properties from %DisplayNames.prototype%.
+
+
+
+ Intl.DisplayNames instances have an [[InitializedDisplayNames]] internal slot.
+
+
+
+ Intl.DisplayNames instances also have several internal slots that are computed by the constructor:
+
+
+
+ - [[Locale]] is a String value with the language tag of the locale whose localization is used for formatting.
+ - [[Style]] is one of the String values *"narrow"*, *"short"*, or *"long"*, identifying the display name style used.
+ - [[Type]] is one of the String values *"language"*, *"region"*, *"script"*, or *"currency"*, identifying the type of the display names requested.
+ - [[Fallback]] is one of the String values *"code"*, or *"none"*, identifying the fallback return when the system does not have the requested display name.
+ - [[Fields]] is a Record (see ) which must have fields with keys corresponding to codes according to [[Style]] and [[Type]].
+
+
+
diff --git a/spec/index.html b/spec/index.html
index 66b5209b..d9a95a45 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -87,6 +87,7 @@
+
diff --git a/spec/overview.html b/spec/overview.html
index a53f68ed..41a87283 100644
--- a/spec/overview.html
+++ b/spec/overview.html
@@ -23,14 +23,14 @@ API Overview
The ECMAScript 2021 Internationalization API Specification is designed to complement the ECMAScript 2021 Language Specification by providing key language-sensitive functionality. The API can be added to an implementation of the ECMAScript 2021 Language Specification (ECMA-262 12th Edition, or successor).
- The ECMAScript 2021 Internationalization API Specification provides several key pieces of language-sensitive functionality that are required in most applications: String comparison (collation), number formatting, date and time formatting, list formatting, pluralization rules, and case conversion. While the ECMAScript 2021 Language Specification provides functions for this basic functionality (on Array.prototype: toLocaleString; on String.prototype: localeCompare, toLocaleLowerCase, toLocaleUpperCase; on Number.prototype: toLocaleString; on Date.prototype: toLocaleString, toLocaleDateString, and toLocaleTimeString), it leaves the actual behaviour of these functions largely up to implementations to define. The ECMAScript 2021 Internationalization API Specification provides additional functionality, control over the language and over details of the behaviour to be used, and a more complete specification of required functionality.
+ The ECMAScript 2021 Internationalization API Specification provides several key pieces of language-sensitive functionality that are required in most applications: String comparison (collation), number formatting, date and time formatting, display names, list formatting, pluralization rules, and case conversion. While the ECMAScript 2021 Language Specification provides functions for this basic functionality (on Array.prototype: toLocaleString; on String.prototype: localeCompare, toLocaleLowerCase, toLocaleUpperCase; on Number.prototype: toLocaleString; on Date.prototype: toLocaleString, toLocaleDateString, and toLocaleTimeString), it leaves the actual behaviour of these functions largely up to implementations to define. The ECMAScript 2021 Internationalization API Specification provides additional functionality, control over the language and over details of the behaviour to be used, and a more complete specification of required functionality.
Applications can use the API in two ways:
-
- Directly, by using the constructors Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat, Intl.ListFormat, or Intl.PluralRules to construct an object, specifying a list of preferred languages and options to configure the behaviour of the resulting object. The object then provides a main function (compare, select, or format), which can be called repeatedly. It also provides a resolvedOptions function, which the application can use to find out the exact configuration of the object.
+ Directly, by using the constructors Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat, Intl.DisplayNames, Intl.ListFormat, or Intl.PluralRules to construct an object, specifying a list of preferred languages and options to configure the behaviour of the resulting object. The object then provides a main function (compare, select, or format), which can be called repeatedly. It also provides a resolvedOptions function, which the application can use to find out the exact configuration of the object.
-
Indirectly, by using the functions of the ECMAScript 2021 Language Specification mentioned above. The collation and formatting functions are respecified in this specification to accept the same arguments as the Collator, NumberFormat, and DateTimeFormat constructors and produce the same results as their compare or format methods. The case conversion functions are respecified to accept a list of preferred languages.