Bug 1201232 - Use Services.intl for Intl.* APIs in Gecko. r?Paolo,pike draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Wed, 24 Jan 2018 11:50:30 -0800
changeset 749044 e4dca1cdec8c7bf0c8971ef1ce2c5ec9b6c040b5
parent 748205 a6c753e77345e968954e8d61e3871c5883015ede
push id97302
push userbmo:gandalf@aviary.pl
push dateTue, 30 Jan 2018 21:36:30 +0000
reviewersPaolo, pike
bugs1201232
milestone60.0a1
Bug 1201232 - Use Services.intl for Intl.* APIs in Gecko. r?Paolo,pike It's a minor change that should align us better with our selection of locales (Services.intl will use user selection of regional preference locales). I also removed the western arabic numeral system limitation to allow persian locales to use eastern arabic numerals correctly. MozReview-Commit-ID: 8TXX0X9RY9z
toolkit/components/narrate/NarrateControls.jsm
toolkit/mozapps/downloads/DownloadUtils.jsm
--- a/toolkit/components/narrate/NarrateControls.jsm
+++ b/toolkit/components/narrate/NarrateControls.jsm
@@ -160,18 +160,17 @@ NarrateControls.prototype = {
    * Returns true if synth voices are available.
    */
   _setupVoices() {
     return this._languagePromise.then(language => {
       this.voiceSelect.clear();
       let win = this._win;
       let voicePrefs = this._getVoicePref();
       let selectedVoice = voicePrefs[language || "default"];
-      let comparer = win.Intl ?
-        (new Intl.Collator()).compare : (a, b) => a.localeCompare(b);
+      let comparer = (new Services.intl.Collator()).compare;
       let filter = !Services.prefs.getBoolPref("narrate.filter-voices");
       let options = win.speechSynthesis.getVoices().filter(v => {
         return filter || !language || v.lang.split("-")[0] == language;
       }).map(v => {
         return {
           label: this._createVoiceLabel(v),
           value: v.voiceURI,
           selected: selectedVoice == v.voiceURI
--- a/toolkit/mozapps/downloads/DownloadUtils.jsm
+++ b/toolkit/mozapps/downloads/DownloadUtils.jsm
@@ -46,27 +46,23 @@ Cu.import("resource://gre/modules/Servic
 
 XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
                                   "resource://gre/modules/PluralForm.jsm");
 
 const MS_PER_DAY = 24 * 60 * 60 * 1000;
 
 var localeNumberFormatCache = new Map();
 function getLocaleNumberFormat(fractionDigits) {
-  // Backward compatibility: don't use localized digits
-  let locale = Intl.NumberFormat().resolvedOptions().locale +
-               "-u-nu-latn";
-  let key = locale + "_" + fractionDigits;
-  if (!localeNumberFormatCache.has(key)) {
-    localeNumberFormatCache.set(key,
-      Intl.NumberFormat(locale,
+  if (!localeNumberFormatCache.has(fractionDigits)) {
+    localeNumberFormatCache.set(fractionDigits,
+      new Services.intl.NumberFormat(undefined,
                         { maximumFractionDigits: fractionDigits,
                           minimumFractionDigits: fractionDigits }));
   }
-  return localeNumberFormatCache.get(key);
+  return localeNumberFormatCache.get(fractionDigits);
 }
 
 const kDownloadProperties =
   "chrome://mozapps/locale/downloads/downloads.properties";
 
 var gStr = {
   statusFormat: "statusFormat3",
   statusFormatInfiniteRate: "statusFormatInfiniteRate",