This proposal is intended to provide translation for strings of particular items which are application-independent, rather than translation for all kinds of strings. There are two classes of strings we're considering here:
Strings that are already available because they're needed for other APIs. For example, names for the days of the week are necessary to provide Intl.DateTimeFormat capabilities. In the absence of a direct API, we see programs parsing the output of Intl.DateTimeFormat to find these names, which is an unreliable/unstable technique.
Strings that are universally standardized and are likely necessary for any multilingual JavaScript application. For example language/region names.
For example, for language/region names, W3C recommends users to use a locale selector when handling multilingual content, and currently that means shipping a long list of translated language/region names with every such website.
Such data may potentially be time and politically sensitive and is unlikely to be specific to any particular website (i.e., it's unlikely that website A will want a different translation of any language name from website B).
For that reason, providing this data in the engine lowers the cost of shipping multilingual websites with locale selectors and move the responsibility for keeping the mapping of BCP47 language/region codes to display names with the engine which is in a better position to keep it up to date.
The set of strings included may grow over time, but we expect to restrict the growth according to pragmatic requirements, including:
Strings which are included should be generically useful across multiple application types.
The inclusion of strings should not be too much of a burden on implementations in terms of data size.
There should be an open data source that implementations can use for the string values, e.g., CLDR.
Strings that rarely (never) change, and thus don't need to be dynamically generated.
Sets of strings that have so few items that it's more of a burden to expose Web API and maintain it forever than it would be for a website to just include those strings directly.
Additional strings included in Intl.DisplayNames should be added to the specification through a future ECMA-402 proposal, to be presented in the ECMA-402 Task Group and TC39 as part of its standardization through TC39 processes.
1.1Abstract Operations for DisplayNames Objects
1.1.1CanonicalCodeForDisplayNames ( 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:
If type is "language", then
If code does not matches the unicode_language_id production, throw a RangeError exceptipon.
If code does not matches the unicode_region_subtag production, throw a RangeError exceptipon.
Let code be the result of mapping code to upper case as described in 6.1.
Return code.
If type is "script", then
If code does not matches the unicode_script_subtag production, throw a RangeError exceptipon.
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 6.1.
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in 9.1.
The value of the [[RelevantExtensionKeys]] internal slot is « ».
The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in 9.1 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.
Note
It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at http://cldr.unicode.org/).
1.4Properties of the Intl.DisplayNames Prototype Object
The Intl.DisplayNames prototype object, referred to as %DisplayNamesPrototype%, is itself an ordinary object. It is not a Intl.DisplayNames instance, does not have an [[InitializedDisplayNames]] internal slot or any of the other internal slots of Intl.DisplayNames instance objects.
1.4.1Intl.DisplayNames.prototype.constructor
The initial value of Intl.DisplayNames.prototype.constructor is the intrinsic object %DisplayNames%.
1.4.2Intl.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 }.
1.4.3Intl.DisplayNames.prototype.of( code )
When the Intl.DisplayNames.prototype.of is called with an argument code, the following steps are taken:
Let displayNames be this value.
If Type(displayNames) is not Object, throw a TypeError exception.
If displayNames does not have an [[InitializedDisplayNames]] internal slot, throw a TypeError exception.
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:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
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.