Bug 1384172 - Expose intl.regional_prefs.use_os_locales in the UI in SeaMonkey. r=frg,IanN; ui-r=IanN
authorrsx11m <rsx11m.pub@gmail.com>
Tue, 06 Feb 2018 23:18:37 -0600
changeset 31052 e90d747e8f57e130ef60f6efbe9ad760c662bc6e
parent 31051 f49ddaee8324f262243320d376c8d6e2e3f852fe
child 31053 cd538cb90f754d0b625c6294a0c18b243905e3e5
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersfrg, IanN, IanN
bugs1384172
Bug 1384172 - Expose intl.regional_prefs.use_os_locales in the UI in SeaMonkey. r=frg,IanN; ui-r=IanN
suite/common/pref/pref-appearance.js
suite/common/pref/pref-appearance.xul
suite/locales/en-US/chrome/common/help/cs_nav_prefs_appearance.xhtml
suite/locales/en-US/chrome/common/pref/pref-appearance.dtd
suite/locales/en-US/chrome/common/pref/prefutilities.properties
--- a/suite/common/pref/pref-appearance.js
+++ b/suite/common/pref/pref-appearance.js
@@ -1,16 +1,20 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+// Load spell-checker module to properly determine language strings
+ChromeUtils.import("resource://gre/modules/InlineSpellChecker.jsm");
+
 function Startup()
 {
   SwitchLocales_Load();
+  NumberLocales_Load();
 }
 
 /**
  * From locale switcher's switch.js:
  * Load available locales into selection menu
  */
 function SwitchLocales_Load() {
   var menulist = document.getElementById("switchLocales");
@@ -75,8 +79,38 @@ function SelectLocale(aElement)
 
   // If prefs can't point us to a valid value and something is set, leave that.
   if (aElement.value)
     return aElement.value;
 
   // If somehow we still have no value, return the first value in the list
   return aElement.firstChild.firstChild.getAttribute("value");
 }
+
+/**
+ * When starting up, determine application and regional locale settings
+ * and add the respective strings to the prefpane labels.
+ */
+function NumberLocales_Load()
+{
+  const osprefs =
+    Components.classes["@mozilla.org/intl/ospreferences;1"]
+              .getService(Components.interfaces.mozIOSPreferences);
+
+  let appLocale = Services.locale.getAppLocalesAsBCP47()[0];
+  let rsLocale = osprefs.getRegionalPrefsLocales()[0];
+  let spellChecker = new InlineSpellChecker();
+  appLocale = spellChecker.getDictionaryDisplayName(appLocale);
+  rsLocale = spellChecker.getDictionaryDisplayName(rsLocale);
+
+  let appLocaleRadio = document.getElementById("appLocale");
+  let rsLocaleRadio = document.getElementById("rsLocale");
+  let prefutilitiesBundle = document.getElementById("bundle_prefutilities");
+
+  let appLocaleLabel = prefutilitiesBundle.getFormattedString("appLocale.label",
+                                                              [appLocale]);
+  let rsLocaleLabel = prefutilitiesBundle.getFormattedString("rsLocale.label",
+                                                             [rsLocale]);
+  appLocaleRadio.setAttribute("label", appLocaleLabel);
+  rsLocaleRadio.setAttribute("label", rsLocaleLabel);
+  appLocaleRadio.accessKey = prefutilitiesBundle.getString("appLocale.accesskey");
+  rsLocaleRadio.accessKey = prefutilitiesBundle.getString("rsLocale.accesskey");
+}
--- a/suite/common/pref/pref-appearance.xul
+++ b/suite/common/pref/pref-appearance.xul
@@ -22,57 +22,75 @@
                   name="browser.chrome.toolbar_style"
                   type="int"/>
       <preference id="browser.chrome.toolbar_tips"
                   name="browser.chrome.toolbar_tips"
                   type="bool"/>
       <preference id="general.useragent.locale"
                   name="general.useragent.locale"
                   type="string"/>
+      <preference id="intl.regional_prefs.use_os_locales"
+                  name="intl.regional_prefs.use_os_locales"
+                  type="bool"/>
     </preferences>
 
-    <groupbox id="generalStartupPreferences" align="start">
-      <caption label="&onStartLegend.label;"/>
+    <hbox>
+      <groupbox id="generalStartupPreferences" align="start" flex="1">
+        <caption label="&onStartLegend.label;"/>
 
-      <checkbox id="generalStartupBrowser"
-                label="&navCheck.label;"
-                accesskey="&navCheck.accesskey;"
-                preference="general.startup.browser"/>
-    </groupbox>
+        <checkbox id="generalStartupBrowser"
+                  label="&navCheck.label;"
+                  accesskey="&navCheck.accesskey;"
+                  preference="general.startup.browser"/>
+      </groupbox>
 
-    <groupbox id="toolbarStyleBox">
-      <caption label="&showToolsLegend.label;"/>
+      <groupbox id="toolbarStyleBox" align="start" flex="1">
+        <caption label="&showToolsLegend.label;"/>
 
-      <radiogroup id="toolbarStyle" orient="horizontal"
-                  preference="browser.chrome.toolbar_style">
-        <radio value="2"
-               label="&picsNtextRadio.label;"
-               accesskey="&picsNtextRadio.accesskey;"/>
-        <radio value="0"
-               label="&picsOnlyRadio.label;"
-               accesskey="&picsOnlyRadio.accesskey;"/>
-        <radio value="1"
-               label="&textonlyRadio.label;"
-               accesskey="&textonlyRadio.accesskey;"/>
-      </radiogroup>
-    </groupbox>
+        <radiogroup id="toolbarStyle"
+                    preference="browser.chrome.toolbar_style">
+          <radio value="2"
+                 label="&picsNtextRadio.label;"
+                 accesskey="&picsNtextRadio.accesskey;"/>
+          <radio value="0"
+                 label="&picsOnlyRadio.label;"
+                 accesskey="&picsOnlyRadio.accesskey;"/>
+          <radio value="1"
+                 label="&textonlyRadio.label;"
+                 accesskey="&textonlyRadio.accesskey;"/>
+        </radiogroup>
+      </groupbox>
+    </hbox>
 
-    <separator class="thin" />
     <vbox class="box-padded" align="start">
       <checkbox id="showHideTooltips"
                 label="&showHideTooltips.label;"
                 accesskey="&showHideTooltips.accesskey;"
                 preference="browser.chrome.toolbar_tips"/>
     </vbox>
 
     <groupbox id="switchLocaleBox" align="start">
       <caption label="&pref.locales.title;"/>
       <description>&selectLocale.label;</description>
 
       <menulist id="switchLocales"
                 preference="general.useragent.locale"
                 onsyncfrompreference="return document.getElementById('appearance_pane').SelectLocale(this);"/>
 
-      <description>&restartOnLangChange.label;</description>
     </groupbox>
 
+    <groupbox id="dateTimeFormatting" align="start">
+      <caption label="&dateTimeFormatting.label;"/>
+      <radiogroup id="formatLocale"
+                  preference="intl.regional_prefs.use_os_locales"
+                  orient="vertical">
+        <radio id="appLocale"
+               value="false"/>
+               <!-- label and accesskey will be set dynamically -->
+        <radio id="rsLocale"
+               value="true"/>
+               <!-- label and accesskey will be set dynamically -->
+      </radiogroup>
+    </groupbox>
+
+    <description>&restartOnLocaleChange.label;</description>
   </prefpane>
 </overlay>
--- a/suite/locales/en-US/chrome/common/help/cs_nav_prefs_appearance.xhtml
+++ b/suite/locales/en-US/chrome/common/help/cs_nav_prefs_appearance.xhtml
@@ -69,21 +69,37 @@
   </li>
   <li><strong>Show Tooltips</strong>: Select this if you want to have 
     <a href="glossary.xhtml#tooltip">tooltips</a> appear when the cursor
     is placed over parts of the &brandShortName; user interface and some
     websites.</li>
   <li><strong>User Interface Language</strong>: This setting allows you to
     change the language used in the user interface of &brandShortName;.
     Additional languages can be installed from the &brandShortName; home page.
-    <strong>Note</strong>: You must restart &brandShortName; for a new language
-    setting to take effect.
+  </li>
+  <li><strong>Date and Time Formatting</strong>: There are usually differences
+    how settings like date and time are formatted, depending on the region
+    (locale). Select how &brandShortName; displays such values:
+    <ul>
+      <li><strong>Application locale</strong>: Select this to show values in
+        the regional way of &brandShortName;&apos;s user interface language.
+      </li>
+      <li><strong>Regional Settings locale</strong>: Select this to show
+        values in the way as defined by your operating system&apos;s settings.
+      </li>
+    </ul>
   </li>
 </ul>
 
+<p><strong>Nots</strong>: You must restart &brandShortName; for a change in
+  language or formatting settings to take effect. In many cases, the choices
+  will show the same language unless you have additional language pack(s)
+  installed or use a localized version of &brandShortName; for a language
+  which is different from your operating-system&apos;s settings.</p>
+
 <p>[<a href="#appearance_preferences">Return to beginning of section</a>]</p>
 
 <h2 id="content">Appearance Preferences - Content</h2>
 
 <p>This section describes how to use the Content preferences panel.
   If you&apos;re not already viewing it, follow these steps:</p>
 
 <ol>
--- a/suite/locales/en-US/chrome/common/pref/pref-appearance.dtd
+++ b/suite/locales/en-US/chrome/common/pref/pref-appearance.dtd
@@ -18,13 +18,18 @@
 <!ENTITY picsOnlyRadio.accesskey                "o">
 <!ENTITY textonlyRadio.label                    "Text only">
 <!ENTITY textonlyRadio.accesskey                "x">
 <!ENTITY showHideTooltips.label                 "Show Tooltips">
 <!ENTITY showHideTooltips.accesskey             "T">
 
 <!ENTITY pref.locales.title                     "User Interface Language">
 <!ENTITY selectLocale.label                     "Select the language for text that appears in dialog boxes, menus, toolbars and button labels:">
-<!--LOCALIZATION NOTE (restartOnLangChange.label): Don't translate "&brandShortName;".
+
+<!--LOCALIZATION NOTE (dateTimeFormatting.label): labels/accesskeys for
+     radiobuttons are set dynamically from prefutilities.properties
+-->
+<!ENTITY dateTimeFormatting.label               "Date and Time Formatting">
+
+<!--LOCALIZATION NOTE (restartOnLocaleChange.label): Don't translate "&brandShortName;".
     Place &brandShortName; in the phrase where the name of the application should appear
 -->
-<!ENTITY restartOnLangChange.label              "Language preferences will take effect when you restart &brandShortName;.">
-
+<!ENTITY restartOnLocaleChange.label            "Language and formatting preferences will take effect when you restart &brandShortName;.">
--- a/suite/locales/en-US/chrome/common/pref/prefutilities.properties
+++ b/suite/locales/en-US/chrome/common/pref/prefutilities.properties
@@ -24,11 +24,20 @@ downloadfolder=Choose a Download Folder
 desktopFolderName=Desktop
 downloadsFolderName=Downloads
 choosesound=Choose a sound
 
 SoundFiles=Sounds
 
 labelDefaultFont=Default (%font_family%)
 
+# LOCALIZATION NOTE (appLocaleString): %S = Name of the application locale,
+# e.g. English (United States)
+appLocale.label=Application locale: %S
+appLocale.accesskey=n
+# LOCALIZATION NOTE (rsLocaleString): %S = Name of the locale chosen in regional settings,
+# e.g. German (Germany)
+rsLocale.label=Regional settings locale: %S
+rsLocale.accesskey=R
+
 syncUnlink.title=Do you want to unlink your device?
 syncUnlink.label=This device will no longer be associated with your Sync account. All of your personal data, both on this device and in your Sync account, will remain intact.
 syncUnlinkConfirm.label=Unlink