Closed Bug 1635561 Opened 5 years ago Closed 5 years ago

Clean up MozIntl

Categories

(Core :: Internationalization, task, P3)

task

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: zbraniecki, Assigned: dminor)

References

Details

Attachments

(4 files)

With the flock of ECMA402 updates landing in SpiderMonkey(*), we should be able to clean up and reduce the scope of MozIntl quite substantially.

This should lead to perf wins due to bug 1504168 and related.

*) bug 1569103, bug 1557718, bug 1589095, bug 1632434

Priority: -- → P3
Depends on: 1639515
Severity: -- → S3

One thing that is left is locale management, and I'd like to explore an option to move locale management used in mozIntl to https://searchfox.org/mozilla-central/source/js/xpconnect/src/XPCLocale.cpp#117-141 - we should just chose the right locale fallback chain for JS environment separately for chrome/non-chrome and then

new Intl.DateTimeformat() in chrome process should return the Firefox UI locale, while in web process should return the web exposed locale chain. This would remove a bit part of mozIntl.

Assignee: nobody → dminor

Having looked at this and Bug 1639515, I think it makes sense to do the cleanup Zibi suggested in Comment 1 first, and then rebase and land Bug 1639515 afterwards. I can pick up a few of the changes unrelated to DisplayNames from 1639515 as part of this bug.

Blocks: 1639515
No longer depends on: 1639515

Not that we use RegionalPrefLocales rather than AppLocale in
xpc_LocalizeRuntime, the wrappers in MozIntl to set this up are no longer
needed.

Depends on D98390

Keeping MozIntl in sync with Intl will allow people to use MozIntl consistently
until we're ready to remove it completely. This is based on work done by André
Bargull for Bug 1639515.

Depends on D98391

This adds Locale to MozIntl and uses it to replaces some instances where we
used regular expressions to parse language tags. It is based on work done by
André Bargull in Bug 1639515.

Depends on D98392

Pushed by dminor@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/05b8c9d0b50d Use RegionalPrefLocales rather than AppLocale in xpc_LocalizeRuntime; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/562e4afa8a10 Remove unnecessary wrappers around Intl in MozIntl; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/21d942cfc35d Add ListFormat to MozIntl; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/d4ef63a42094 Add Locale to MozIntl; r=zbraniecki

I think the problem is that with these changes [1] we use the first item in the regionalPrefsLocales array but with the getLocales wrapper in mozIntl.jsm, we use the full array [2]. I think this makes a difference when we attempt to resolve the locale at [3].

The test that is failing calls localeService.negotiateLanguages [4] to determine the default locale if no locales are specified. I think we need to either change the code in XPCLocale.cpp to also call NegotiateLanguages, or change the test expectations to not do so. I'm guessing we'd want to add the call to NegotiateLanguages in XPCLocale but I'm not completely sure.

Zibi, what do you think?

[1] https://hg.mozilla.org/integration/autoland/rev/05b8c9d0b50d#l1.21
[2] https://searchfox.org/mozilla-central/source/toolkit/components/mozintl/mozIntl.jsm#26
[3] https://searchfox.org/mozilla-central/source/js/src/builtin/intl/IntlObject.js#209
[4] https://searchfox.org/mozilla-central/source/dom/tests/mochitest/chrome/test_intlUtils_getLocaleInfo.html#21

Flags: needinfo?(dminor) → needinfo?(gandalf)

I dug into this a little deeper, and I was completely wrong about the array stuff, I only have one entry on my system anyway.

As far as I can tell, the difference is the call to NegotiateLanguages. On my system, my regionalPrefsLocale is "en-CA" and my availableLocales is "en-US", and we end up using "en-US". Prior to my changes, we used the app locale in XPCLocale, which is also "en-US" and the test passed. With my changes, we now use the regionalPrefsLocale in XPCLocale, which is "en-CA", and the test fails.

Flags: needinfo?(gandalf)
Pushed by dminor@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ee7bed950965 Use RegionalPrefLocales rather than AppLocale in xpc_LocalizeRuntime; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/36bff8882d55 Remove unnecessary wrappers around Intl in MozIntl; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/fa5240689523 Add ListFormat to MozIntl; r=zbraniecki https://hg.mozilla.org/integration/autoland/rev/47eb8c778c41 Add Locale to MozIntl; r=zbraniecki
Blocks: 1681306
Regressions: 1681357
Regressions: 1685075
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: