Bug 1493313 - Port bug 1491394: Replace {get|set}XxxLocales() with xxxLocales. r=aceman
authorJorg K <jorgk@jorgk.com>
Sat, 22 Sep 2018 02:09:06 +0200
changeset 33205 a01d1481ef18bb394581e01a9c5950829aae22a4
parent 33204 97064b1acf5339bb5e78fd2f90bac5a4ea332d76
child 33206 ed984c4258e99aacdeaae73ba7a63f2719178516
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersaceman
bugs1493313, 1491394
Bug 1493313 - Port bug 1491394: Replace {get|set}XxxLocales() with xxxLocales. r=aceman
calendar/base/content/calendar-extract.js
calendar/base/src/calStartupService.js
calendar/providers/gdata/modules/gdataSession.jsm
mail/base/modules/distribution.js
mail/base/modules/mailMigrator.js
mail/base/test/unit/test_mailGlue_distribution.js
mail/components/mailGlue.js
mail/components/newmailaccount/content/accountProvisioner.js
mail/components/preferences/advanced.js
mail/components/preferences/messengerLanguages.js
mail/test/mozmill/newmailaccount/test-newmailaccount.js
--- a/calendar/base/content/calendar-extract.js
+++ b/calendar/base/content/calendar-extract.js
@@ -85,17 +85,17 @@ var calendarExtract = {
                                                   32768,
                                                   false,
                                                   true,
                                                   { });
         cal.LOG("[calExtract] Original email content: \n" + title + "\r\n" + content);
         let date = new Date(message.date / 1000);
         let time = (new Date()).getTime();
 
-        let locale = Services.locale.getRequestedLocale();
+        let locale = Services.locale.requestedLocale;
         let dayStart = Preferences.get("calendar.view.daystarthour", 6);
         let extractor;
 
         if (fixedLang) {
             extractor = new Extractor(fixedLocale, dayStart);
         } else {
             extractor = new Extractor(locale, dayStart, false);
         }
--- a/calendar/base/src/calStartupService.js
+++ b/calendar/base/src/calStartupService.js
@@ -57,17 +57,17 @@ calStartupService.prototype = {
         let tzService = Components.classes["@mozilla.org/calendar/timezone-service;1"]
                                   .getService(Components.interfaces.calITimezoneService);
         let calMgr = Components.classes["@mozilla.org/calendar/manager;1"]
                                .getService(Components.interfaces.calICalendarManager);
 
         // Localization service
         let locales = {
             startup: function(aCompleteListener) {
-                let packaged = Services.locale.getPackagedLocales();
+                let packaged = Services.locale.packagedLocales;
                 let fileSrc = new FileSource(
                     "calendar", packaged,
                     "resource://calendar/chrome/calendar-{locale}/locale/{locale}/"
                 );
                 L10nRegistry.registerSource(fileSrc);
                 aCompleteListener.onResult(null, Components.results.NS_OK);
             },
             shutdown: function(aCompleteListener) {
--- a/calendar/providers/gdata/modules/gdataSession.jsm
+++ b/calendar/providers/gdata/modules/gdataSession.jsm
@@ -133,17 +133,17 @@ calGoogleSession.prototype = {
         let authDescr = getProviderString("requestWindowDescription", sessionId);
         let authTitle = getProviderString("requestWindowTitle", sessionId);
 
         // Set up a new OAuth2 instance for logging in.
         this.oauth = new OAuth2(OAUTH_BASE_URI, OAUTH_SCOPE, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET);
         this.oauth.extraAuthParams = [
           ["login_hint", sessionId],
           // Use application locale for login dialog
-          ["hl", Services.locale.getRequestedLocale()]
+          ["hl", Services.locale.requestedLocale]
         ];
         this.oauth.requestWindowURI = "chrome://gdata-provider/content/browserRequest.xul";
         this.oauth.requestWindowFeatures = "chrome,private,centerscreen,width=430,height=750";
         this.oauth.requestWindowTitle = authTitle;
         this.oauth.requestWindowDescription = authDescr;
 
         // Overwrite the refreshToken attribute, since we want to save it in
         // the password manager
--- a/mail/base/modules/distribution.js
+++ b/mail/base/modules/distribution.js
@@ -127,17 +127,17 @@ XPCOMUtils.defineLazyGetter(TBDistCustom
               .getService(Ci.nsIINIParserFactory)
               .createINIParser(iniFile);
     }
     return ini;
 });
 
 XPCOMUtils.defineLazyGetter(TBDistCustomizer, "_locale",
   function TBDistCustomizer_get__locale() {
-    return Services.locale.getRequestedLocale();
+    return Services.locale.requestedLocale;
 });
 
 function enumToObject(UTF8Enumerator) {
   let ret = {};
   while (UTF8Enumerator.hasMore()) {
     ret[UTF8Enumerator.getNext()] = 1
   }
   return ret;
--- a/mail/base/modules/mailMigrator.js
+++ b/mail/base/modules/mailMigrator.js
@@ -373,23 +373,23 @@ var MailMigrator = {
       if (currentUIVersion < 16) {
         // Migrate the old requested locales prefs to use the new model
         const SELECTED_LOCALE_PREF = "general.useragent.locale";
         const MATCHOS_LOCALE_PREF = "intl.locale.matchOS";
 
         if (Services.prefs.prefHasUserValue(MATCHOS_LOCALE_PREF) ||
             Services.prefs.prefHasUserValue(SELECTED_LOCALE_PREF)) {
           if (Services.prefs.getBoolPref(MATCHOS_LOCALE_PREF, false)) {
-            Services.locale.setRequestedLocales([]);
+            Services.locale.requestedLocales = [];
           } else {
             let locale = Services.prefs.getComplexValue(SELECTED_LOCALE_PREF,
               Ci.nsIPrefLocalizedString);
             if (locale) {
               try {
-                Services.locale.setRequestedLocales([locale.data]);
+                Services.locale.requestedLocales = [locale.data];
               } catch (e) { /* Don't panic if the value is not a valid locale code. */ }
             }
           }
           Services.prefs.clearUserPref(SELECTED_LOCALE_PREF);
           Services.prefs.clearUserPref(MATCHOS_LOCALE_PREF);
         }
       }
 
--- a/mail/base/test/unit/test_mailGlue_distribution.js
+++ b/mail/base/test/unit/test_mailGlue_distribution.js
@@ -1,16 +1,16 @@
 ChromeUtils.import("resource:///modules/distribution.js");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function run_test()
 {
   do_test_pending();
 
-  Services.locale.setRequestedLocales(["en-US"]);
+  Services.locale.requestedLocales = ["en-US"];
 
   // Create an instance of nsIFile out of the current process directory
   let distroDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
 
   // Construct a descendant of the distroDir file
   distroDir.append("distribution");
 
   // Create a clone of distroDir
--- a/mail/components/mailGlue.js
+++ b/mail/components/mailGlue.js
@@ -151,17 +151,17 @@ MailGlue.prototype = {
   // nsIMailGlue implementation
   sanitize: function MG_sanitize(aParentWindow) {
     this._sanitizer.sanitize(aParentWindow);
   },
 
   _onProfileStartup: function MailGlue__onProfileStartup() {
     TBDistCustomizer.applyPrefDefaults();
 
-    let locales = Services.locale.getPackagedLocales();
+    let locales = Services.locale.packagedLocales;
     const appSource = new FileSource("app", locales, "resource:///localization/{locale}/");
     L10nRegistry.registerSource(appSource);
 
     // handle any migration work that has to happen at profile startup
     MailMigrator.migrateAtProfileStartup();
 
     // check if we're in safe mode
     if (Services.appinfo.inSafeMode) {
--- a/mail/components/newmailaccount/content/accountProvisioner.js
+++ b/mail/components/newmailaccount/content/accountProvisioner.js
@@ -112,17 +112,17 @@ var EmailAccountProvisioner = {
   get suggestFromName() {
     return Services.prefs.getCharPref("mail.provider.suggestFromName");
   },
 
   /**
    * Returns the language that the user currently accepts.
    */
   get userLanguage() {
-    return Services.locale.getRequestedLocale();
+    return Services.locale.requestedLocale;
   },
 
   /**
    * A helper function to enable or disable the Search button.
    */
   searchButtonEnabled: function EAP_searchButtonEnabled(aVal) {
     document.getElementById("searchSubmit").disabled = !aVal;
   },
--- a/mail/components/preferences/advanced.js
+++ b/mail/components/preferences/advanced.js
@@ -490,66 +490,66 @@ var gAdvancedPane = {
     appLocaleRadio.accessKey = this.mBundle.getString("appLocale.accesskey");
     rsLocaleRadio.accessKey = this.mBundle.getString("rsLocale.accesskey");
   },
 
   // Load the preferences string bundle for other locales with fallbacks.
   getBundleForLocales(newLocales) {
     let locales = Array.from(new Set([
       ...newLocales,
-      ...Services.locale.getRequestedLocales(),
+      ...Services.locale.requestedLocales,
       Services.locale.lastFallbackLocale,
     ]));
     function generateContexts(resourceIds) {
       return L10nRegistry.generateContexts(locales, resourceIds);
     }
     return new Localization([
       "messenger/preferences/preferences.ftl",
       "branding/brand.ftl",
     ], generateContexts);
   },
 
   initMessengerLocale() {
-    let localeCodes = Services.locale.getAvailableLocales();
+    let localeCodes = Services.locale.availableLocales;
     let localeNames = Services.intl.getLocaleDisplayNames(undefined, localeCodes);
     let locales = localeCodes.map((code, i) => ({code, name: localeNames[i]}));
     locales.sort((a, b) => a.name > b.name);
 
     let fragment = document.createDocumentFragment();
     for (let {code, name} of locales) {
       let menuitem = document.createElement("menuitem");
       menuitem.setAttribute("value", code);
       menuitem.setAttribute("label", name);
       fragment.appendChild(menuitem);
     }
     let menulist = document.getElementById("defaultMessengerLanguage");
     let menupopup = menulist.querySelector("menupopup");
     menupopup.appendChild(fragment);
-    menulist.value = Services.locale.getRequestedLocale();
+    menulist.value = Services.locale.requestedLocale;
 
     document.getElementById("messengerLanguagesBox").hidden = false;
   },
 
   showMessengerLanguages() {
     gSubDialog.open(
       "chrome://messenger/content/preferences/messengerLanguages.xul",
       null, this.requestingLocales, this.messengerLanguagesClosed);
   },
 
   /* Show or hide the confirm change message bar based on the updated ordering. */
   messengerLanguagesClosed() {
     let requesting = this.gMessengerLanguagesDialog.requestedLocales;
-    let requested = Services.locale.getRequestedLocales();
+    let requested = Services.locale.requestedLocales;
     let defaultMessengerLanguage = document.getElementById("defaultMessengerLanguage");
     if (requesting && requesting.join(",") != requested.join(",")) {
       gAdvancedPane.showConfirmLanguageChangeMessageBar(requesting);
       defaultMessengerLanguage.value = requesting[0];
       return;
     }
-    defaultMessengerLanguage.value = Services.locale.getRequestedLocale();
+    defaultMessengerLanguage.value = Services.locale.requestedLocale;
     gAdvancedPane.hideConfirmLanguageChangeMessageBar();
   },
 
   /* Show the confirmation message bar to allow a restart into the new locales. */
   async showConfirmLanguageChangeMessageBar(locales) {
     let messageBar = document.getElementById("confirmMessengerLanguage");
     // Set the text in the message bar for the new locale.
     let newBundle = this.getBundleForLocales(locales);
@@ -574,32 +574,32 @@ var gAdvancedPane = {
 
   /* Confirm the locale change and restart the Thunderbird in the new locale. */
   confirmLanguageChange() {
     let localesString = (event.target.getAttribute("locales") || "").trim();
     if (!localesString || localesString.length == 0) {
       return;
     }
     let locales = localesString.split(",");
-    Services.locale.setRequestedLocales(locales);
+    Services.locale.requestedLocales = locales;
 
     // Restart with the new locale.
     let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
     Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
     if (!cancelQuit.data) {
       Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart);
     }
   },
 
   /* Show or hide the confirm change message bar based on the new locale. */
   onMessengerLanguageChange(event) {
     let locale = event.target.value;
-    if (locale == Services.locale.getRequestedLocale()) {
+    if (locale == Services.locale.requestedLocale) {
       this.hideConfirmLanguageChangeMessageBar();
       return;
     }
     let locales = Array.from(new Set([
       locale,
-      ...Services.locale.getRequestedLocales(),
+      ...Services.locale.requestedLocales,
     ]).values());
     this.showConfirmLanguageChangeMessageBar(locales);
   },
 };
--- a/mail/components/preferences/messengerLanguages.js
+++ b/mail/components/preferences/messengerLanguages.js
@@ -190,17 +190,17 @@ class SortedItemSelectList {
     let item = document.createElement("menuitem");
     item.value = value;
     item.setAttribute("label", label);
     return item;
   }
 }
 
 function getLocaleDisplayInfo(localeCodes) {
-  let packagedLocales = new Set(Services.locale.getPackagedLocales());
+  let packagedLocales = new Set(Services.locale.packagedLocales);
   let localeNames = Services.intl.getLocaleDisplayNames(undefined, localeCodes);
   return localeCodes.map((code, i) => {
     return {
       id: "locale-" + code,
       label: localeNames[i],
       value: code,
       canRemove: !packagedLocales.has(code),
     };
@@ -216,19 +216,19 @@ var gMessengerLanguagesDialog = {
     this.requestedLocales = this._requestedLocales.items.map(item => item.value);
     return true;
   },
 
   onLoad() {
     // Maintain the previously requested locales even if we cancel out.
     this.requestedLocales = window.arguments[0];
 
-    let requested = this.requestedLocales || Services.locale.getRequestedLocales();
+    let requested = this.requestedLocales || Services.locale.requestedLocales;
     let requestedSet = new Set(requested);
-    let available = Services.locale.getAvailableLocales()
+    let available = Services.locale.availableLocales
       .filter(locale => !requestedSet.has(locale));
 
     this.initRequestedLocales(requested);
     this.initAvailableLocales(available);
     this.initialized = true;
   },
 
   initRequestedLocales(requested) {
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -44,39 +44,39 @@ var NAME = "Leonard Shelby";
 
 // Record what the original value of the mail.provider.enabled pref is so
 // that we can put it back once the tests are done.
 var gProvisionerEnabled = Services.prefs.getBoolPref(kProvisionerEnabledPref);
 
 // Record what the original value of the mail.provider.enabled pref is so
 // that we can put it back once the tests are done.
 var gProvisionerEnabled = Services.prefs.getBoolPref(kProvisionerEnabledPref);
-var gOldAcceptLangs = Services.locale.getRequestedLocales();
+var gOldAcceptLangs = Services.locale.requestedLocales;
 var gNumAccounts;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
   // Make sure we enable the Account Provisioner.
   Services.prefs.setBoolPref(kProvisionerEnabledPref, true);
   // Restrict the user's language to just en-US
-  Services.locale.setRequestedLocales(["en-US"]);
+  Services.locale.requestedLocales = ["en-US"];
 
   // Add a "bar" search engine that we can switch to be the default.
   Services.search.addEngineWithDetails("bar", null, null, null, "post",
                                        "http://www.example.com/search");
 };
 
 function teardownModule(module) {
   // Put the mail.provider.enabled pref back the way it was.
   Services.prefs.setBoolPref(kProvisionerEnabledPref, gProvisionerEnabled);
   // And same with the user languages
-  Services.locale.setRequestedLocales(gOldAcceptLangs);
+  Services.locale.requestedLocales = gOldAcceptLangs;
 }
 
 /* Helper function that returns the number of accounts associated with the
  * current profile.
  */
 function nAccounts() {
   return MailServices.accounts.accounts.length;
 }
@@ -1119,30 +1119,30 @@ function subtest_disabled_fields_when_se
 
 /**
  * Tests that the search button is disabled if there is no initially
  * supported language for the user.
  */
 function test_search_button_disabled_if_no_lang_support() {
   // Set the user's supported language to something ridiculous (caching the
   // old one so we can put it back later).
-  let originalReqLocales = Services.locale.getRequestedLocales();
-  Services.locale.setRequestedLocales(["foo"]);
+  let originalReqLocales = Services.locale.requestedLocales;
+  Services.locale.requestedLocales = ["foo"];
 
   plan_for_modal_dialog("AccountCreation", function(aController) {
     wait_for_provider_list_loaded(aController);
     // The search button should be disabled.
     wait_for_element_enabled(aController, aController.e("searchSubmit"), false);
     close_dialog_immediately(aController);
   });
 
   open_provisioner_window();
   wait_for_modal_dialog("AccountCreation");
 
-  Services.locale.setRequestedLocales(originalReqLocales);
+  Services.locale.requestedLocales = originalReqLocales;
 }
 
 /**
  * Subtest used by several functions that checks to make sure that the
  * search button is disabled when the Account Provisioner dialog is opened,
  * in case there's no search input yet.
  */
 function subtest_search_button_enabled_state_on_init(aController) {
@@ -1158,28 +1158,28 @@ function subtest_search_button_enabled_s
 }
 
 /**
  * Test that if the providerList contains entries with supported languages
  * including "*", they are always displayed, even if the users locale pref
  * is not set to "*".
  */
 function test_provider_language_wildcard() {
-  let originalReqLocales = Services.locale.getRequestedLocales();
-  Services.locale.setRequestedLocales(["foo-ba"]);
+  let originalReqLocales = Services.locale.requestedLocales;
+  Services.locale.requestedLocales = ["foo-ba"];
 
   let original = Services.prefs.getCharPref(kProviderListPref);
   Services.prefs.setCharPref(kProviderListPref, url + "providerListWildcard");
 
   plan_for_modal_dialog("AccountCreation",
                         subtest_provider_language_wildcard);
   open_provisioner_window();
   wait_for_modal_dialog("AccountCreation");
   Services.prefs.setCharPref(kProviderListPref, original);
-  Services.locale.setRequestedLocales(originalReqLocales);
+  Services.locale.requestedLocales = originalReqLocales;
 }
 
 /**
  * Subtest used by test_provider_language_wildcard, ensures that the
  * "Universal" and "OtherUniversal" providers are displayed, but the French
  * and German ones are not.
  */
 function subtest_provider_language_wildcard(aController) {