Bug 1440490 - Move l10n related functions into calL10NUtils.jsm - part 2 - migrate formatMonth/sortArrayByLocaleCollator/createLocaleCollator. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Thu, 22 Feb 2018 07:38:37 +0100
changeset 31380 6e8d7aef9631f3d31a92c1262c74fe5595e415af
parent 31379 10085a3cc8a189498141c21b58018f277e0055fc
child 31381 5250ba1d9d41e15629fe93b30b150562a303de1c
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersMakeMyDay
bugs1440490
Bug 1440490 - Move l10n related functions into calL10NUtils.jsm - part 2 - migrate formatMonth/sortArrayByLocaleCollator/createLocaleCollator. r=MakeMyDay MozReview-Commit-ID: V07uSxVwgX
calendar/base/content/calendar-views.xml
calendar/base/content/preferences/categories.js
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/content/widgets/minimonth.xml
calendar/base/src/calDateTimeFormatter.js
calendar/import-export/calMonthGridPrinter.js
calendar/lightning/content/lightning-item-iframe.js
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -247,18 +247,18 @@
             if (aDate) {
                 aDate = aDate.getInTimezone(this.timezone);
             }
             this.showDate(aDate);
         ]]></body>
       </method>
       <method name="getRangeDescription">
         <body><![CDATA[
-            let monthName = cal.formatMonth(this.rangeStartDate.month + 1,
-                                            "calendar", "monthInYear");
+            let monthName = cal.l10n.formatMonth(this.rangeStartDate.month + 1,
+                                                 "calendar", "monthInYear");
             return cal.calGetString("calendar", "monthInYear", [monthName, this.rangeStartDate.year]);
         ]]></body>
        </method>
       <method name="moveView">
         <parameter name="aNumber"/>
         <body><![CDATA[
             let dates = this.getDateList({});
             this.displayDaysOff = !this.mWorkdaysOnly;
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -71,17 +71,17 @@ var gCategoriesPane = {
     },
 
     /**
      * Updates the listbox containing the categories from the categories saved
      * in preferences.
      */
 
     updatePrefs: function() {
-        cal.sortArrayByLocaleCollator(gCategoryList);
+        cal.l10n.sortArrayByLocaleCollator(gCategoryList);
         document.getElementById("calendar.categories.names").value =
             cal.category.arrayToString(gCategoryList);
     },
 
     updateCategoryList: function() {
         this.updatePrefs();
         let listbox = document.getElementById("categorieslist");
 
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -181,17 +181,17 @@
       </method>
 
       <method name="loadItem">
         <parameter name="aItem"/>
         <body><![CDATA[
             let categoryListbox = document.getAnonymousElementByAttribute(this, "anonid", "categories-listbox");
             let categoryList = cal.category.fromPrefs();
 
-            cal.sortArrayByLocaleCollator(categoryList);
+            cal.l10n.sortArrayByLocaleCollator(categoryList);
 
             removeChildren(categoryListbox);
 
             for (let cat of categoryList) {
                 // First insert all categories from the prefs
                 let item = categoryListbox.appendItem(cat, cat);
                 item.setAttribute("type", "checkbox");
             }
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -866,18 +866,18 @@
 
             // get today's date
             let today = new Date();
 
             if (aDate.getFullYear() == (this.mValue || this.mExtraDate).getFullYear()) {
                 calbox.setAttribute("aria-label", cal.calGetString("dateFormat",
                                     "month." + (aDate.getMonth() + 1) + ".name"));
             } else {
-                let monthName = cal.formatMonth(aDate.getMonth() + 1,
-                                                "calendar", "monthInYear");
+                let monthName = cal.l10n.formatMonth(aDate.getMonth() + 1,
+                                                     "calendar", "monthInYear");
                 let label = cal.calGetString("calendar", "monthInYear",
                                          [monthName, aDate.getFullYear()]);
                 calbox.setAttribute("aria-label", label);
             }
 
             this.mDayMap = {};
             let defaultTz = cal.dtz.defaultTimezone;
             let dateFormatter =
--- a/calendar/base/src/calDateTimeFormatter.js
+++ b/calendar/base/src/calDateTimeFormatter.js
@@ -121,25 +121,30 @@ calDateTimeFormatter.prototype = {
             if (sameDay) {
                 return this.formatDateLong(aStartDate);
             } else {
                 let startDay = this.formatDayWithOrdinal(aStartDate.day);
                 let startYear = aStartDate.year;
                 let endDay = this.formatDayWithOrdinal(endDate.day);
                 let endYear = endDate.year;
                 if (aStartDate.year != endDate.year) {
-                    let startMonthName = cal.formatMonth(aStartDate.month + 1, "calendar", "daysIntervalBetweenYears");
-                    let endMonthName = cal.formatMonth(aEndDate.month + 1, "calendar", "daysIntervalBetweenYears");
+                    let startMonthName = cal.l10n.formatMonth(aStartDate.month + 1, "calendar",
+                                                              "daysIntervalBetweenYears");
+                    let endMonthName = cal.l10n.formatMonth(aEndDate.month + 1, "calendar",
+                                                            "daysIntervalBetweenYears");
                     return cal.calGetString("calendar", "daysIntervalBetweenYears", [startMonthName, startDay, startYear, endMonthName, endDay, endYear]);
                 } else if (aStartDate.month == endDate.month) {
-                    let startMonthName = cal.formatMonth(aStartDate.month + 1, "calendar", "daysIntervalInMonth");
+                    let startMonthName = cal.l10n.formatMonth(aStartDate.month + 1, "calendar",
+                                                              "daysIntervalInMonth");
                     return cal.calGetString("calendar", "daysIntervalInMonth", [startMonthName, startDay, endDay, endYear]);
                 } else {
-                    let startMonthName = cal.formatMonth(aStartDate.month + 1, "calendar", "daysIntervalBetweenMonths");
-                    let endMonthName = cal.formatMonth(aEndDate.month + 1, "calendar", "daysIntervalBetweenMonths");
+                    let startMonthName = cal.l10n.formatMonth(aStartDate.month + 1, "calendar",
+                                                              "daysIntervalBetweenMonths");
+                    let endMonthName = cal.l10n.formatMonth(aEndDate.month + 1, "calendar",
+                                                            "daysIntervalBetweenMonths");
                     return cal.calGetString("calendar", "daysIntervalBetweenMonths", [startMonthName, startDay, endMonthName, endDay, endYear]);
                 }
             }
         } else {
             let startDateString = this.formatDate(aStartDate);
             let startTime = this.formatTime(aStartDate);
             let endDateString = this.formatDate(endDate);
             let endTime = this.formatTime(endDate);
--- a/calendar/import-export/calMonthGridPrinter.js
+++ b/calendar/import-export/calMonthGridPrinter.js
@@ -149,17 +149,17 @@ calMonthPrinter.prototype = {
         let monthContainer = document.getElementById("month-container");
 
         // Clone the template month and make sure it doesn't have an id
         let currentMonth = monthTemplate.cloneNode(true);
         currentMonth.removeAttribute("id");
         currentMonth.item = startOfMonth.clone();
 
         // Set up the month title
-        let monthName = cal.formatMonth(startOfMonth.month + 1, "calendar", "monthInYear");
+        let monthName = cal.l10n.formatMonth(startOfMonth.month + 1, "calendar", "monthInYear");
         let monthTitle = cal.calGetString("calendar", "monthInYear", [monthName, startOfMonth.year]);
         currentMonth.querySelector(".month-name").textContent = monthTitle;
 
         // Set up the weekday titles
         let wkst = Preferences.get("calendar.week.start", 0);
         for (let i = 1; i <= 7; i++) {
             let dayNumber = ((i + wkst - 1) % 7) + 1;
             let dayTitle = currentMonth.querySelector(".day" + i + "-title");
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -593,17 +593,17 @@ function loadDialog(aItem) {
         if (indexToSelect > -1) {
             calendarList.selectedIndex = indexToSelect;
         }
     }
 
     // Categories
     if (gNewItemUI) {
         // XXX more to do here with localization, see loadCategories.
-        itemProps.initialCategoriesList = cal.sortArrayByLocaleCollator(cal.category.fromPrefs());
+        itemProps.initialCategoriesList = cal.l10n.sortArrayByLocaleCollator(cal.category.fromPrefs());
         itemProps.initialCategories = aItem.getCategories({});
 
         // just to demo capsules component
         itemProps.initialCategories = ["Some", "Demo", "Categories"];
     } else {
         loadCategories(aItem);
     }