Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigator.locales to expose additional locale details #3046

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="js-RangeError" data-x-href="https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></dfn> class</li>
<li>The <dfn data-x="js-typeof" data-x-href="https://tc39.github.io/ecma262/#sec-typeof-operator"><code>typeof</code></dfn> operator</li>
<li><dfn data-x-href="https://tc39.github.io/ecma262/#table-49">The <var>TypedArray</var> Constructors</dfn> table</li>
<li>The <dfn data-x-href="https://zbraniecki.github.io/proposal-intl-locale/#sec-intl-locale-constructor"><code>Intl.Locale</code></dfn> class</li>
</ul>

</dd>
Expand Down Expand Up @@ -91375,12 +91376,14 @@ interface <dfn>NavigatorID</dfn> {

<!-- next section refers to previous section as "previous section" -->

<h5>Language preferences</h5>
<h5>Language and locale preferences</h5>

<pre class="idl">[NoInterfaceObject, Exposed=(Window,Worker)]
interface <dfn>NavigatorLanguage</dfn> {
readonly attribute DOMString <span data-x="dom-navigator-language">language</span>;
readonly attribute FrozenArray&lt;DOMString&gt; <span data-x="dom-navigator-languages">languages</span>;

readonly attribute FrozenArray&lt;Intl.Locale&gt; <span data-x="dom-navigator-locales">locales</span>;
};</pre>

<dl class="domintro">
Expand All @@ -91397,6 +91400,14 @@ interface <dfn>NavigatorLanguage</dfn> {
<p>The most preferred language is the one returned by <code
data-x="dom-navigator-language">navigator.language</code>.</p>
</dd>

<dt><var>self</var> . <code data-x="dom-navigator">navigator</code> . <code subdfn
data-x="dom-navigator-locales">locales</code></dt>
<dd>
<p>Returns an array of <code>Intl.Locale</code> objects representing the user's preferred locales,
with the most preferred locale first. These locales may include additional Unicode extension tags
such as the user's preferred calendar, numbering system, etc.</p>
</dd>
</dl>

<p class="note">A <code data-x="event-languagechange">languagechange</code> event is fired at the
Expand Down Expand Up @@ -91429,6 +91440,9 @@ interface <dfn>NavigatorLanguage</dfn> {
returned until the user agent needs to return different values, or values in a different order.
<ref spec=BCP47></p>

<p>The language tags contained returned must include only language, region and script, excluding
extensions.</p>

<p>Whenever the user agent needs to make the <code
data-x="dom-navigator-languages">navigator.languages</code> attribute of a <code>Window</code>
or <code>WorkerGlobalScope</code> object return a new set of language tags, the user agent must
Expand All @@ -91442,6 +91456,20 @@ interface <dfn>NavigatorLanguage</dfn> {

</dd>

<dt><dfn><code data-x="dom-navigator-locales">locales</code></dfn></dt>
<dd>

<p>Must return a <span>frozen array</span> of <code>Intl.Locale</code> objects representing either one
or more <span data-x="a plausible language">plausible languages</span>, or the user's preferred
locales, ordered by preference with the most preferred language first. The same object must be
returned until the user agent needs to return different values, or values in a different order.</p>

<p>The <code>Intl.Locale</code> objects provided may include additional Unicode extension tags such
as the user's preferred calendar, numbering system, etc. These may be set by operating system settings,
for example.</p>

</dd>

</dl>

<p>To determine <dfn>a plausible language</dfn>, the user agent should bear in mind the following:</p>
Expand Down