Bug 1414872 - Fix always adding source locale to requested locales fallback chain. r=jfkthame
authorZibi Braniecki <zbraniecki@mozilla.com>
Mon, 06 Nov 2017 09:01:35 -0800
changeset 443636 f993b9f8f20c13aa55c5abc9d39a22c92f68bf3a
parent 443635 b4a8921258e0f11594eb6bf4e38f91eb606fb0ca
child 443637 82e2afb4d9046d7113ba0cdc19588a79575e84d5
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1414872
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)