VERIFIED CONFIGURATION CHANGED 197213
[INTL] en-NZ locale defaults to en-US locale instead of using en-NZ
https://bugs.webkit.org/show_bug.cgi?id=197213
Summary [INTL] en-NZ locale defaults to en-US locale instead of using en-NZ
Daniel Compton
Reported 2019-04-23 14:59:28 PDT
When using Intl.DateTimeFormat/Intl.NumberFormat in the New Zealand locale (en-NZ), if you use Intl.DateTimeFormat() or Intl.DateTimeFormat("default"), 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 & 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("default").resolvedOptions().locale, new Intl.DateTimeFormat().resolvedOptions().locale, new Intl.DateTimeFormat().format(new Date())] Current output: // In the Australia region: => ["en-AU", "en-AU", "24/04/2019"] // In United Kingdom => ["en-GB", "en-GB", "24/04/2019"] // In United States => ["en-US", "en-US", "4/24/2019"] // In New Zealand (this one shows the problem) => ["en-US", "en-US", "4/24/2019"] Expected output for New Zealand: ["en-NZ", "en-NZ", "24/04/2019"] JavaScriptCore does correctly format the output if the en-NZ locale is specified: [new Intl.DateTimeFormat("en-NZ").resolvedOptions().locale, new Intl.DateTimeFormat("en-NZ").format(new Date())] => ["en-NZ", "en-US", "24/04/2019"] 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
Attachments
Alexey Proskuryakov
Comment 1 2019-04-26 20:18:14 PDT
I suspect that JavaScriptCore ends up using bundle localization for default locale, which actually feels correct - it's not great when browser UI and webpage content use different languages and formats. Safari happens to have "en", "en_AU" and "en_GB" localizations, but no "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. That's a good idea. Unlike the main issue reported here, such logic definitely wouldn'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
Daniel Compton
Comment 2 2019-04-28 11:25:57 PDT
Thanks for the feedback, it makes sense how this is happening. I've opened rdar://50280505 for the Foundation enhancement. Feel free to close this issue if there's no further actions to take available in WebKit.
Daniel Compton
Comment 3 2019-04-28 11:27:00 PDT
Also, I forgot to mention that I really appreciated the full explanation of what is happening. Thanks!
Alexey Proskuryakov
Comment 4 2019-04-29 10:43:44 PDT
Leaving open for the JSC folks to confirm whether they agree that this is expected behavior.
Andy VanWagoner
Comment 5 2019-04-30 15:22:36 PDT
JSC looks up the default locale from its embedder (Foundation or WebCore), falling back to libicu's default locale, and ultimately to "en" if none of those others had a value. Resolving to a "closest" default locale is not specified in the ECMA 402 spec, but I agree "en-US" isn't a great fit for "en-NZ". I can't speak to where the logic ultimately would need to change (Foundation, WebCore, or elsewhere in Safari), but it's not currently in JSC. Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`?
Daniel Compton
Comment 6 2019-05-02 15:42:48 PDT
> Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`? Yes, with macOS in the NZ Locale, Safari shows: > [navigator.language, Intl.DateTimeFormat().resolvedOptions().locale] < ["en-US", "en-US"]
Andy VanWagoner
Comment 7 2019-05-02 19:55:03 PDT
(In reply to Daniel Compton from comment #6) > > Does `navigator.language` agree with `Intl.DateTimeFormat().resolvedOptions().locale`? > > Yes, with macOS in the NZ Locale, Safari shows: > > > [navigator.language, Intl.DateTimeFormat().resolvedOptions().locale] > < ["en-US", "en-US"] Ok, good. Intl apis are behaving as expected, then.
Ross Kirsling
Comment 8 2020-04-14 18:15:46 PDT
Closing as I'm seeing `new Intl.DateTimeFormat("en-NZ").resolvedOptions().locale` return "en-NZ" in STP 104 on Catalina. Please reopen if there's still an issue here.
Daniel Compton
Comment 9 2020-04-14 21:21:40 PDT
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("default").resolvedOptions().locale, new Intl.DateTimeFormat().resolvedOptions().locale, new Intl.DateTimeFormat().format(new Date()), navigator.language] => ["en-AU", "en-AU", "15/04/2020", "en-au"] Running the same in STP Release 104 (Safari 13.2, WebKit 15610.1.8.3) returns: => ["en-US", "en-US", "4/15/2020", "en-us"]
Alexey Proskuryakov
Comment 10 2020-04-15 09:59:55 PDT
Could you please file a new bug about this? I did't see the same problem with Russian, although I found a different regression, bug 210554. In the new bug, please provide the output of "defaults read -g AppleLanguages; defaults read -g AppleLocale" on your machine.
Note You need to log in before you can comment on or make changes to this bug.