Bug 1414872 - Fix always adding source locale to requested locales fallback chain. r?jfkthame draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Mon, 06 Nov 2017 09:01:35 -0800
changeset 693608 1eece077ac08e2c95bda8cabdac14bc715319ebb
parent 693279 e7fee7042d971d73c0e5caafba3b8d15da1bc8ca
child 739099 fc5643bb39d43ba028ea326412e2288ce3407baf
push id87875
push userbmo:gandalf@aviary.pl
push dateMon, 06 Nov 2017 17:01:53 +0000
reviewersjfkthame
bugs1414872
milestone58.0a1
Bug 1414872 - Fix always adding source locale to requested locales fallback chain. r?jfkthame MozReview-Commit-ID: CwvBkEJqQRi
intl/locale/LocaleService.cpp
--- 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)