Gecko Locale Selection remodel completed (repost from dev.platform)
Zbigniew Braniecki (Gandalf)
zbraniecki at mozilla.com
Tue Mar 28 15:58:57 UTC 2017
Hi Firefox devs!
We just landed the final change that culminates the 3 month long major
refactor of how Gecko handles language selection  (pending
We now have a single new API - mozilla::intl::LocaleService  (and
mozILocaleService ) - which centralizes all operations related to things
like asking for languages that the user requested, which language resources
are available and which languages have been negotiated for the app to use.
Also, all events related to those operations are now distributed from the
On top of that, we gained an additional helper API for retrieving
Internationalization-related infromation from the operating system -
mozilla::intl::OSPreferences  (and mozIOSPreferences ).
We migrated all the code in mozilla-central to use the new code  for
you, but if your work uses those areas, please make sure to take a look at
those APIs and start using them in your code.
In particular, please use `LocaleService::getAppLocalesAs(BCP47|LangTags)`
for all code that wants to follow the current UI language, and use
LocaleService's `getRequestedLocales` and `setRequestedLocales` instead of
manipulating `general.useragent.locale` pref directly .
JS Context and mozIntl APIs now use the current browser UI language
selection instead of OS locales.
That change also marks the beginning of deprecation of the
nsILocaleService, nsLocaleSerivice, nsLocale and related APIs .
Lastly, we've moved away from ChromeRegistry as the central place for
negotiating language selection for the product (LocaleService takes over
that role), which means that in almost all cases you should consult
LocaleService, not ChromeRegistry.
This last step opens up the ability for us to introduce a new localization
resources registry  which will slowly take over that role from
There are still a couple minor features we'll be adding to LocaleService
over the next month , but generally, the API is complete and ready to
handle centralized language management in Gecko.
Beyond cleaning up 20+ year old code, unifying the behavior and enabling
the new registry, those changes put us on a path to more flexible
multi-lingual behavior aligned with the modern Web.
>From here, we plan to make Gecko be able to:
- decouple release of the product from the releases of language resources
- handle localization of HTML/WebComponents/WebExtensions/XUL/XBL/JS using
a single localization API
- better align between language resources and Intl APIs (date/number
- deliver language resource updates on the fly
- gain control over at what point in the UI loading we inject strings
- change languages on fly
- first step on the path to the end of .DTD and .properties
- handle error scenarios better (death to the Yellow Screen of Death!)
Team responsible for the refactor: :gandalf, :jfkthame, :pike, and :stas.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the firefox-dev