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 222426 88c4d076e3db761496aa55dd6ab971739c4e24e6
parent 222425 5b030e48e8b0835368d091936830a48df62f34a2
child 222541 c6b66f2272252f2f0b3b59e1df19be2b1ab32eb5
push id10688
push usermbanner@mozilla.com
push dateWed, 07 Jan 2015 20:08:23 +0000
treeherderfx-team@88c4d076e3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1117863
milestone37.0a1
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 {