Bug 1117863 - Correct Loop's language fallback to use all of accept languages properly. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Wed, 07 Jan 2015 20:08:01 +0000
changeset 222608 88c4d076e3db761496aa55dd6ab971739c4e24e6
parent 222475 5b030e48e8b0835368d091936830a48df62f34a2
child 222609 c6b66f2272252f2f0b3b59e1df19be2b1ab32eb5
push id28069
push usercbook@mozilla.com
push dateThu, 08 Jan 2015 13:36:51 +0000
treeherdermozilla-central@f90dccb788ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1117863
milestone37.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 1117863 - Correct Loop's language fallback to use all of accept languages properly. r=mikedeboer
browser/components/loop/standalone/content/libs/l10n-gaia-02ca67948fe8.js
--- a/browser/components/loop/standalone/content/libs/l10n-gaia-02ca67948fe8.js
+++ b/browser/components/loop/standalone/content/libs/l10n-gaia-02ca67948fe8.js
@@ -1236,21 +1236,29 @@
 
       return locales[code] = new Locale(code, this);
     };
 
 
     // Getting ready
 
     function negotiate(available, requested, defaultLocale) {
-      if (available.indexOf(requested[0]) === -1 ||
-          requested[0] === defaultLocale) {
+      var supportedLocale;
+      for (var i = 0; i < requested.length; ++i) {
+        var locale = requested[i];
+        if (available.indexOf(locale) !== -1) {
+          supportedLocale = locale;
+          break;
+        }
+      }
+      if (!supportedLocale ||
+          supportedLocale === defaultLocale) {
         return [defaultLocale];
       } else {
-        return [requested[0], defaultLocale];
+        return [supportedLocale, defaultLocale];
       }
     }
 
     function freeze(supported) {
       var locale = this.getLocale(supported[0]);
       if (locale.isReady) {
         setReady.call(this, supported);
       } else {