Skip to content

Commit

Permalink
Bug 1491654 - Add lastFallbackLocale at the end of AppLocales. r=jfkt…
Browse files Browse the repository at this point in the history
…hame

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Zibi Braniecki committed Sep 18, 2018
1 parent 0a9605a commit 7775d0c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions intl/locale/LocaleService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,21 @@ LocaleService::NegotiateAppLocales(nsTArray<nsCString>& aRetVal)

NegotiateLanguages(requestedLocales, availableLocales, defaultLocale,
LangNegStrategy::Filtering, aRetVal);
} else {
// In content process, we will not do any language negotiation.
// Instead, the language is set manually by SetAppLocales.
//
// If this method has been called, it means that we did not fire
// SetAppLocales yet (happens during initialization).
// In that case, all we can do is return the default or last fallback locale.
//
// We will return last fallback here, to avoid having to trigger reading
// `update.locale` for default locale.
}

nsAutoCString lastFallbackLocale;
GetLastFallbackLocale(lastFallbackLocale);

if (!aRetVal.Contains(lastFallbackLocale)) {
// This part is used in one of the two scenarios:
//
// Once SetAppLocales will be called later, it'll fire an event
// allowing callers to update the locale.
nsAutoCString lastFallbackLocale;
GetLastFallbackLocale(lastFallbackLocale);
// a) We're in a client mode, and no locale has been set yet,
// so we need to return last fallback locale temporarily.
// b) We're in a server mode, and the last fallback locale was excluded
// when negotiating against the requested locales.
// Since we currently package it as a last fallback at build
// time, we should also add it at the end of the list at
// runtime.
aRetVal.AppendElement(lastFallbackLocale);
}
}
Expand Down

0 comments on commit 7775d0c

Please sign in to comment.