Closed Bug 1399203 Opened 7 years ago Closed 7 years ago

Locale defaults to "en-ZA" when in Vancouver, Canada for FF 55.0.2 on Ubuntu

Categories

(Core :: JavaScript: Internationalization API, defect, P3)

55 Branch
All
Linux
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox55 --- affected
firefox56 --- affected
firefox57 --- affected

People

(Reporter: blaak, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

Steps to reproduce:

On FF 55 in Ubuntu 16.04.3 this code does not return the correct result:

var f = new Intl.NumberFormat("us", {maximumFractionDigits: 2, useGrouping: true});
f.format(1.25);


Actual results:

It returns "1,25"


Expected results:

It should return "1.25"

That comma makes breaks parsing back to a number for US locales.

Note that things work correctly with FF 55 on MacOS, as well as FF 51 on Unbuntu 16.04.2.
As a work around, if I use "en-us" instead of "us", then things work fine.
Component: Untriaged → JavaScript: Internationalization API
Product: Firefox → Core
"us" is not a valid BCP 47 language tag [1], so `Intl.NumberFormat("us")` creates number formatter for the current default locale. You can check the actual locale used through the Intl.NumberFormat.prototype.resolvedOptions() [2] method.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
Fair enough, I will use en-us instead.

However, the problem then is that the locale is incorrect for my geo region. I am in Vancouver, Canada, and just installed FF 55 as part of Ubuntu 16.04.3. 

Given the example above, f.resolvedOptions() reports "en-ZA" as the value for the locale. 

Shouldn't it report en-CA or perhaps en-US?

This problem did not occur with FF 51 in Ubuntu 16.04.2. It also works fine on FF 55.0.3 on my Mac.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Summary: Intl.NumberFormat bug with "us" locale in FF 55.0.2 on Ubuntu → locale defaults to "en-ZA" when in Vancouver, Canada for FF 55.0.2 on Ubuntu
> I am in Vancouver, Canada, and just installed FF 55 as part of Ubuntu 16.04.3. 

Can you open `about:config` and tell me what's your value of `general.useragent.locale` flag?

And optionally open Developer Tools, Browser Console and check the result of `Services.locale.getAppLocalesAsLangTags();` command?

Thank you!
general.useragent.locale reports as en-ZA
intl.accept_languages reports as en-US

On the console, navigator.language reports as en-US

Services.locale.getAppLocalesAsLangTags() won't parse for me in the console, I get a "ReferenceError: Services is not defined" error.
I am not sure what I did, attempted to view the Browser Console explicitly, but now the Web Console allows me to parse the Services.locale.getAppLocalesAsLangTags call. It now returns:

["en-ZA", "en-GB", "en-US"]

Note that I have just changed my preferences to keep only the en-US language, but the above is still reporting en-ZA, etc.
Note also, that Service.locale.defaultLocale is returning en-US
whereas Service.locale.getAppLocaleAsLangTag() is returning en-ZA
Thank Ray!

You need to launch the browser console, not the regular developer console (one is operating in the context of a webpage, the other is operating in the context of the Firefox UI app).

Anyway, your general.useragent.locale being en-ZA is the problem.

`Service.locale.defaultLocale` is just the last resort fallback locale we'll use if nothing else matches.

I'm wondering how did it happen that your general.useragent.locale pref is set to en-ZA. It shouldn't be unless you selected en-ZA while installing Ubuntu and it downloaded language pack for you somehow.

If you change it to "en-US" I expect you'll have the correct locale, but it's worrying for me that this value has been set to en-ZA.

How did you install Firefox in Ubuntu? Did it come with the system?

Do you have any language packs installed? Is en-ZA your locale in Ubuntu? I'm confused.
I added no language packs, just included FF as part of the Ubuntu install for 16.04.2. I.e. it came with the system. 

It asked me if I was in Vancouver, which I affirmed. This gave me FF 51 which ran fine.

I then upgraded to Ubuntu 16.04.3, which included FF 55.0.2. 

At no time did I install any language packs or override any locale configuration further.

FF 55 showed the en-ZA, en-GB, and en-US languages in the preferences by this point.
Note also, that Ubuntu itself is correctly saying my current language setting is for English (Canada).
Thank you!

I'll try to reproduce it today. I'm starting to be worried that something is wrong with our Ubuntu packaging locale selection for Canada.
Flags: needinfo?(gandalf)
Ray, can you give me the result of `Services.locale.getAvailableLocales();` please?
Flags: needinfo?(blaak)
See Also: → 1389709
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Linux
Hardware: Unspecified → All
Summary: locale defaults to "en-ZA" when in Vancouver, Canada for FF 55.0.2 on Ubuntu → Locale defaults to "en-ZA" when in Vancouver, Canada for FF 55.0.2 on Ubuntu
Zibi, for me `Services.locale.getAvailableLocales();` returns `["en-ZA", "en-GB", "en-US"]`
Flags: needinfo?(blaak)
Ok, so this is related to bug  1389709 where we also map en-CA to en-ZA.

The only thing I struggle to understand is why you have en-ZA in your locales. In bug  1389709 we talk about Fennec which does build so called multilocale package with almost 100 locales, so the presence of en-ZA is understandable.

But in your case, I'm not sure I understand how you ended up on Ubuntu with a locale data for en-ZA.

I'll work on a patch to match en-US over en-ZA for en-CA tomorrow.
I have a patch in bug 1400006 that will fix the matching. I can't explain why you have resources for en-ZA, but this patch will make us match against en-US over en-ZA.
Flags: needinfo?(gandalf)
No longer blocks: 1400006
Depends on: 1400006
This should be fixed in Nightly starting today.

I'm going to close this bug, please reopen if you encounter it again in Nightly.
Status: NEW → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
Notice, that I still don't understand how the reported ended up with en-ZA language resources in their browser. I merely fixed the negotiation algorithm to pick en-US above en-ZA for requested language "en-CA".

But the case of why en-ZA was at all available for a user in en-CA is probably unrelated and has something to do with ubuntu packaging.
You need to log in before you can comment on or make changes to this bug.