Bug 526554: Show 'auto detect' in locale list when locale is set to 'auto detect' using matchOS [r=gavin.sharp]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 04 Nov 2009 17:34:37 -0500
changeset 65758 c6029e2f1f0d61f7a9a1c7e41e898247bee9470c
parent 65757 99d4ad5e19e9756444220a96ef3faf14412f08ad
child 65759 456c735dcaf59c6fb9122e8ba1f517f80b3bce19
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin.sharp
bugs526554
Bug 526554: Show 'auto detect' in locale list when locale is set to 'auto detect' using matchOS [r=gavin.sharp]
mobile/chrome/content/browser.xul
mobile/chrome/content/preferences.js
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -378,17 +378,17 @@
 #else
                         oncommand="BrowserUI.newTab('about:fennec', true);"/>
 #endif
               </setting>
               <setting id="prefs-uilanguage" title="&language.title;" type="control">
                 &language.description;
                 <menulist id="prefs-languages" oncommand="PreferencesView.updateLocale();">
                   <menupopup>
-                    <menuitem label="&language.auto;" value="auto"/>
+                    <menuitem id="prefs-languages-auto" label="&language.auto;" value="auto"/>
                   </menupopup>
                 </menulist>
                </setting>
               <settings id="prefs-content" label="&content.title;">
                 <setting pref="permissions.default.image" title="&showImages.title;" type="boolint" on="1" off="2"/>
                 <setting pref="javascript.enabled" type="bool" title="&enableJavaScript.title;">
                   &enableJavaScript.description;
                 </setting>
--- a/mobile/chrome/content/preferences.js
+++ b/mobile/chrome/content/preferences.js
@@ -145,19 +145,29 @@ var PreferencesView = {
       }
       let item = this._list.appendItem(label, locale);
       if (locale == selectedLocale) {
         this._currentLocale = locale;
         selectedItem = item;
       }
       localeCount++;
     }
-            
-    // Highlight current locale
-    this._list.selectedItem = selectedItem;
+
+    // Are we using auto-detection?
+    let autoDetect = false;
+    try {
+      autoDetect = gPrefService.getBoolPref("intl.locale.matchOS");
+    }
+    catch (e) {}
+    
+    // Highlight current locale (or auto-detect entry)
+    if (autoDetect)
+      this._list.selectedItem = document.getElementById("prefs-languages-auto");
+    else
+      this._list.selectedItem = selectedItem;
     
     // Hide the setting if we only have one locale
     if (localeCount == 1)
       document.getElementById("prefs-uilanguage").hidden = true;
   },
   
   updateLocale: function updateLocale() {
     // Which locale did the user select?