Bug 1479606 - Sync BCP47 language tags between processes, not lang tags. r=jfkthame

Sync BCP47 language tags between processes, not lang tags.

Differential Revision: https://phabricator.services.mozilla.com/D2579

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2018-07-31 21:42:37 +00:00
parent 6ecd2e45dd
commit a0c2cfd168
2 changed files with 16 additions and 1 deletions

View File

@ -3169,7 +3169,7 @@ ContentParent::Observe(nsISupports* aSubject,
}
else if (!strcmp(aTopic, "intl:app-locales-changed")) {
nsTArray<nsCString> appLocales;
LocaleService::GetInstance()->GetAppLocalesAsLangTags(appLocales);
LocaleService::GetInstance()->GetAppLocalesAsBCP47(appLocales);
Unused << SendUpdateAppLocales(appLocales);
}
else if (!strcmp(aTopic, "intl:requested-locales-changed")) {

View File

@ -315,6 +315,11 @@ LocaleService::GetRequestedLocales(nsTArray<nsCString>& aRetVal)
bool
LocaleService::GetAvailableLocales(nsTArray<nsCString>& aRetVal)
{
MOZ_ASSERT(mIsServer, "This should only be called in the server mode.");
if (!mIsServer) {
return false;
}
if (mAvailableLocales.IsEmpty()) {
// If there are no available locales set, it means that L10nRegistry
// did not register its locale pool yet. The best course of action
@ -903,6 +908,11 @@ NS_IMETHODIMP
LocaleService::SetRequestedLocales(const char** aRequested,
uint32_t aRequestedCount)
{
MOZ_ASSERT(mIsServer, "This should only be called in the server mode.");
if (!mIsServer) {
return NS_ERROR_UNEXPECTED;
}
nsAutoCString str;
for (uint32_t i = 0; i < aRequestedCount; i++) {
@ -949,6 +959,11 @@ NS_IMETHODIMP
LocaleService::SetAvailableLocales(const char** aAvailable,
uint32_t aAvailableCount)
{
MOZ_ASSERT(mIsServer, "This should only be called in the server mode.");
if (!mIsServer) {
return NS_ERROR_UNEXPECTED;
}
nsTArray<nsCString> newLocales;
for (uint32_t i = 0; i < aAvailableCount; i++) {