intl.accept_languages is not in canonical form on Android, but all lower case
Categories
(GeckoView :: General, defect, P3)
Tracking
(firefox109 fixed)
Tracking | Status | |
---|---|---|
firefox109 | --- | fixed |
People
(Reporter: robwu, Assigned: zmckenney)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug)
Attachments
(1 file)
In https://phabricator.services.mozilla.com/D151606?id=616048#inline-852560, we observed that the i18n.getAcceptLanguages
extension API returned en-us
(lowercase us
instead of en-US, en
as on desktop).
It looks like the missing fallback , en
seems to be addressed in bug 1765375.
Still, the en-us
part being full-lowercase is not ideal. It looks like the implementation in GeckoViewStartup.jsm explicitly turns everything to lower case. This should be <lowercase>-<uppercase>
instead.
The Accept-Language header doesn't rely on the exact casing, because the pref value is processed and turned into a canonical format (also with q-values added).
For reference, this is the full call stack that I traced to get to the root cause of the observed issue:
i18n.getAcceptedLanguages
is implemented at https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/toolkit/components/extensions/parent/ext-i18n.js#25- it is the value of the
intl.accept_languages
pref - https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/toolkit/components/extensions/ExtensionCommon.jsm#2077-2082 intl.accept_languages
is localized, with the value specified byintl.properties
at https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/modules/libpref/init/all.js#1782- for the
en-US
locale, it's defined to been-US, en
- https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/toolkit/locales/en-US/chrome/global/intl.properties#23
... but on Android (i.e. GeckoView), all of that is overridden at https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/mobile/android/components/geckoview/GeckoViewStartup.jsm#253-266
called via https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java#786
... which sets everything to lowercase.
Comment 1•2 years ago
|
||
We'll also need to stop lowercasing the locale identifiers returned by the OS:
This code lowercases the locale identifiers because it wants to detect duplicate locale identifiers (that may have different capitalization). If we want to keep that check, then this function will need to build two lists of locale identifiers:
- the list of lowercased locale identifiers to detect duplicate locale identifiers (that may have different capitalization)
- a list of the locale identifiers with their original capitalization (but still no duplicates) that the function returns at the end
This might be a good first bug because the fix is contained in only one function.
Updated•2 years ago
|
Assignee | ||
Comment 2•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 4•2 years ago
|
||
bugherder |
Description
•