<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>197213</bug_id>
          
          <creation_ts>2019-04-23 14:59:28 -0700</creation_ts>
          <short_desc>[INTL] en-NZ locale defaults to en-US locale instead of using en-NZ</short_desc>
          <delta_ts>2020-04-15 09:59:55 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Compton">desk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andy</cc>
    
    <cc>ap</cc>
    
    <cc>beidson</cc>
    
    <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>ross.kirsling</cc>
    
    <cc>thorton</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1529774</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Compton">desk</who>
    <bug_when>2019-04-23 14:59:28 -0700</bug_when>
    <thetext>When using Intl.DateTimeFormat/Intl.NumberFormat in the New Zealand locale (en-NZ), if you use Intl.DateTimeFormat() or Intl.DateTimeFormat(&quot;default&quot;), JavaScriptCore resolves the locale to the en-US locale. This only seems to happen for New Zealand. When macOS is using the United Kingdom, USA, or Australia locales, JavaScriptCore returns the expected locale.

Reproduction steps:

* Open Language &amp; Region in System Preferences
* Change the Region to the region under test
* Open a Safari web-page and the Web Inspector
* Run this statements in the Console:

[new Intl.DateTimeFormat(&quot;default&quot;).resolvedOptions().locale,
new Intl.DateTimeFormat().resolvedOptions().locale,
new Intl.DateTimeFormat().format(new Date())]

Current output:

// In the Australia region:
=&gt; [&quot;en-AU&quot;, &quot;en-AU&quot;, &quot;24/04/2019&quot;]

// In United Kingdom
=&gt; [&quot;en-GB&quot;, &quot;en-GB&quot;, &quot;24/04/2019&quot;]

// In United States
=&gt; [&quot;en-US&quot;, &quot;en-US&quot;, &quot;4/24/2019&quot;]

// In New Zealand (this one shows the problem)
=&gt; [&quot;en-US&quot;, &quot;en-US&quot;, &quot;4/24/2019&quot;]

Expected output for New Zealand:

[&quot;en-NZ&quot;, &quot;en-NZ&quot;, &quot;24/04/2019&quot;]

JavaScriptCore does correctly format the output if the en-NZ locale is specified:

[new Intl.DateTimeFormat(&quot;en-NZ&quot;).resolvedOptions().locale,
new Intl.DateTimeFormat(&quot;en-NZ&quot;).format(new Date())]
=&gt; [&quot;en-NZ&quot;, &quot;en-US&quot;, &quot;24/04/2019&quot;]

I would expect that the default locale returned by JavaScriptCore matches the system locale, especially where JavaScriptCore does support that locale like en-NZ. If en-NZ is not supported, then I would probably expect to default to en-AU, and failing that en-GB. Both of those locales are more similar to en-NZ than en-US is.

Tested in
Safari Technology Preview: Release 80 (Safari 12.2, WebKit 14608.1.16)
Safari: Version 12.1 (14607.1.40.1.4)

Other notes:

I tested this briefly in Chrome and Firefox for the NZ region. Chrome returns en-NZ as the default locale, Firefox has the same behaviour as Safari</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1530920</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-04-26 20:18:14 -0700</bug_when>
    <thetext>I suspect that JavaScriptCore ends up using bundle localization for default locale, which actually feels correct - it&apos;s not great when browser UI and webpage content use different languages and formats. Safari happens to have &quot;en&quot;, &quot;en_AU&quot; and &quot;en_GB&quot; localizations, but no &quot;en_NZ&quot;.

&gt; If en-NZ is not supported, then I would probably expect to default to en-AU, and failing that en-GB. Both of those locales are more similar to en-NZ than en-US is.

That&apos;s a good idea. Unlike the main issue reported here, such logic definitely wouldn&apos;t be in WebKit though, it would be in Foundation. WebKit relies on underlying system to resolve locales, so Foundation would need to decide that en_AU should be used instead of the default. Please feel welcome to file a bug for Apple to consider via https://bugreport.apple.com</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531063</commentid>
    <comment_count>2</comment_count>
    <who name="Daniel Compton">desk</who>
    <bug_when>2019-04-28 11:25:57 -0700</bug_when>
    <thetext>Thanks for the feedback, it makes sense how this is happening. I&apos;ve opened rdar://50280505 for the Foundation enhancement. Feel free to close this issue if there&apos;s no further actions to take available in WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531064</commentid>
    <comment_count>3</comment_count>
    <who name="Daniel Compton">desk</who>
    <bug_when>2019-04-28 11:27:00 -0700</bug_when>
    <thetext>Also, I forgot to mention that I really appreciated the full explanation of what is happening. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531187</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-04-29 10:43:44 -0700</bug_when>
    <thetext>Leaving open for the JSC folks to confirm whether they agree that this is expected behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1531726</commentid>
    <comment_count>5</comment_count>
    <who name="Andy VanWagoner">andy</who>
    <bug_when>2019-04-30 15:22:36 -0700</bug_when>
    <thetext>JSC looks up the default locale from its embedder (Foundation or WebCore), falling back to libicu&apos;s default locale, and ultimately to &quot;en&quot; if none of those others had a value.

Resolving to a &quot;closest&quot; default locale is not specified in the ECMA 402 spec, but I agree &quot;en-US&quot; isn&apos;t a great fit for &quot;en-NZ&quot;.

I can&apos;t speak to where the logic ultimately would need to change (Foundation, WebCore, or elsewhere in Safari), but it&apos;s not currently in JSC.

Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1532490</commentid>
    <comment_count>6</comment_count>
    <who name="Daniel Compton">desk</who>
    <bug_when>2019-05-02 15:42:48 -0700</bug_when>
    <thetext>&gt; Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`?

Yes, with macOS in the NZ Locale, Safari shows:

&gt; [navigator.language, Intl.DateTimeFormat().resolvedOptions().locale]
&lt; [&quot;en-US&quot;, &quot;en-US&quot;]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1532605</commentid>
    <comment_count>7</comment_count>
    <who name="Andy VanWagoner">andy</who>
    <bug_when>2019-05-02 19:55:03 -0700</bug_when>
    <thetext>(In reply to Daniel Compton from comment #6)
&gt; &gt; Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`?
&gt; 
&gt; Yes, with macOS in the NZ Locale, Safari shows:
&gt; 
&gt; &gt; [navigator.language, Intl.DateTimeFormat().resolvedOptions().locale]
&gt; &lt; [&quot;en-US&quot;, &quot;en-US&quot;]

Ok, good. Intl apis are behaving as expected, then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641636</commentid>
    <comment_count>8</comment_count>
    <who name="Ross Kirsling">ross.kirsling</who>
    <bug_when>2020-04-14 18:15:46 -0700</bug_when>
    <thetext>Closing as I&apos;m seeing `new Intl.DateTimeFormat(&quot;en-NZ&quot;).resolvedOptions().locale` return &quot;en-NZ&quot; in STP 104 on Catalina.

Please reopen if there&apos;s still an issue here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641669</commentid>
    <comment_count>9</comment_count>
    <who name="Daniel Compton">desk</who>
    <bug_when>2020-04-14 21:21:40 -0700</bug_when>
    <thetext>I think this is fixed, though there may be a regression in STP?

Running this on Safari 13.1, macOS 10.15.4 in NZ region:

[new Intl.DateTimeFormat(&quot;default&quot;).resolvedOptions().locale,
new Intl.DateTimeFormat().resolvedOptions().locale,
new Intl.DateTimeFormat().format(new Date()),
navigator.language]

=&gt; [&quot;en-AU&quot;, &quot;en-AU&quot;, &quot;15/04/2020&quot;, &quot;en-au&quot;] 

Running the same in STP Release 104 (Safari 13.2, WebKit 15610.1.8.3) returns:

=&gt; [&quot;en-US&quot;, &quot;en-US&quot;, &quot;4/15/2020&quot;, &quot;en-us&quot;]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1641847</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2020-04-15 09:59:55 -0700</bug_when>
    <thetext>Could you please file a new bug about this? I did&apos;t see the same problem with Russian, although I found a different regression, bug 210554.

In the new bug, please provide the output of &quot;defaults read -g AppleLanguages; defaults read -g AppleLocale&quot; on your machine.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>