Bug 1414872 - Fix always adding source locale to requested locales fallback chain. r?jfkthame
MozReview-Commit-ID: CwvBkEJqQRi
--- a/intl/locale/LocaleService.cpp
+++ b/intl/locale/LocaleService.cpp
@@ -90,16 +90,26 @@ ReadRequestedLocales(nsTArray<nsCString>
// Otherwise, we'll try to get the requested locale from the prefs.
if (!NS_SUCCEEDED(Preferences::GetCString(SELECTED_LOCALE_PREF, locale))) {
return false;
}
// At the moment we just take a single locale, but in the future
// we'll want to allow user to specify a list of requested locales.
aRetVal.AppendElement(locale);
+
+ // en-US is a LastResort locale. LastResort locale is a fallback locale
+ // for the requested locale chain. In the future we'll want to make the
+ // fallback chain differ per-locale. For now, it'll always fallback on en-US.
+ //
+ // Notice: This is not the same as DefaultLocale,
+ // which follows the default locale the build is in.
+ if (!locale.Equals("en-US")) {
+ aRetVal.AppendElement("en-US");
+ }
return true;
}
static bool
ReadAvailableLocales(nsTArray<nsCString>& aRetVal)
{
nsCOMPtr<nsIToolkitChromeRegistry> cr =
mozilla::services::GetToolkitChromeRegistryService();
@@ -288,25 +298,16 @@ LocaleService::AssignRequestedLocales(co
}
bool
LocaleService::GetRequestedLocales(nsTArray<nsCString>& aRetVal)
{
if (mRequestedLocales.IsEmpty()) {
ReadRequestedLocales(mRequestedLocales);
- // en-US is a LastResort locale. LastResort locale is a fallback locale
- // for the requested locale chain. In the future we'll want to make the
- // fallback chain differ per-locale. For now, it'll always fallback on en-US.
- //
- // Notice: This is not the same as DefaultLocale,
- // which follows the default locale the build is in.
- if (!mRequestedLocales.Contains("en-US")) {
- mRequestedLocales.AppendElement("en-US");
- }
}
aRetVal = mRequestedLocales;
return true;
}
bool
LocaleService::GetAvailableLocales(nsTArray<nsCString>& aRetVal)