Hi devs,

intl/locale is going through a refactor phase to get us ready for the new 
localization framework and the new l10n UX [0].

As part of it, we just landed a new LocaleService that is going to take over 
from nsLocaleService and nsChromeRegistry as the API for locale negotiation for 
the platform.

The bottom line is that starting today, we'd like to move all call-sites that 
are looking to use the current locale fallback chain of the application to use:

C++ [1]

```
nsTArray<nsCString> appLocales;
mozilla::intl::LocaleService::GetInstance()->GetAppLocales(appLocales);
```

JS [2]:

```
const localeService = Components.classes["@mozilla.org/intl/localeservice;1"]
  .getService(Components.interfaces.mozILocaleService);

const appLocales = localeService.getAppLocales();
```

If your code can handle only one locale there's a helper `GetAppLocale` which 
will retrieve just the top one, but in general, we want to move to APIs that 
take full fallback chain to better fallback in case the first locale is not 
available (that's how our l10n and intl code will work).

We started unifying all call-sites to the new API [3] and we'd love to get some 
help, so if you're maintaining any Gecko code that currently retrieves the 
current app locale, please help us by migrating your code.

And if you're working on new code, use only this service from now on as we'll 
try to deprecate the others.

Thanks,
zb.

p.s. The logic inside LocaleService will be maintained by our team and we'll be 
improving that to use preferences from the OS, and new Firefox Preferences UI 
in the future together with full language negotiation.

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1325870
[1] http://searchfox.org/mozilla-central/source/intl/locale/LocaleService.h#43
[2] 
https://hg.mozilla.org/mozilla-central/file/tip/intl/locale/mozILocaleService.idl#l19
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1334772
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to