Bug 1440490 - Move l10n related functions into calL10NUtils.jsm - part 5 - migrate getDateFmtString. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Thu, 22 Feb 2018 09:18:15 +0100
changeset 31383 3e0fec7cfb1b94b6707a96d749338e072e5e93be
parent 31382 4151d5bee5b7d4a491556ea4e3ed57f36fb4ed62
child 31384 2d043b6dc896494dbef7661f36497151cecb6f51
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 5 - migrate getDateFmtString. r=MakeMyDay MozReview-Commit-ID: 65lJM28zm91
calendar/base/content/agenda-listbox.xml
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-task-tree.xml
calendar/base/content/today-pane.js
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/content/widgets/minimonth.xml
calendar/import-export/calMonthGridPrinter.js
calendar/resources/content/datetimepickers/datetimepickers.xml
calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
--- a/calendar/base/content/agenda-listbox.xml
+++ b/calendar/base/content/agenda-listbox.xml
@@ -240,18 +240,18 @@
                 duration = longFormat ? dateFormatter.formatDateTime(start)
                                       : dateFormatter.formatTime(start);
             } else if (endDate.compare(periodStartDate) >= 0 &&
                        endDate.compare(periodEndDate) <= 0) {
                 // event spanning multiple days, end date within period
                 iconType = "end";
                 if (endAtMidnight) {
                     duration = dateFormatter.formatDate(endDate) + " ";
-                    duration = longFormat ? duration + cal.calGetString("dateFormat", "midnight")
-                                          : cal.calGetString("dateFormat", "midnight");
+                    duration = longFormat ? duration + cal.l10n.getDateFmtString("midnight")
+                                          : cal.l10n.getDateFmtString("midnight");
                 } else {
                     duration = longFormat ? dateFormatter.formatDateTime(end)
                                           : dateFormatter.formatTime(end);
                 }
             } else {
                 iconType = "continue";
             }
             let multiDayImage = document.getAnonymousElementByAttribute(this, "anonid", "agenda-multiDayEvent-image");
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -219,17 +219,17 @@
             // Set up DOM attributes for custom CSS coloring.
             let weekTitle = cal.getWeekInfoService().getWeekTitle(aDate);
             this.setAttribute("year", aDate.year);
             this.setAttribute("month", aDate.month + 1);
             this.setAttribute("week", weekTitle);
             this.setAttribute("day", aDate.day);
 
             if (this.mShowMonthLabel) {
-                let monthName = cal.calGetString("dateFormat", "month." + (aDate.month + 1) + ".Mmm");
+                let monthName = cal.l10n.getDateFmtString(`month.${aDate.month + 1}.Mmm`);
                 this.setAttribute("value", aDate.day + " " + monthName);
             } else {
                 this.setAttribute("value", aDate.day);
             }
         ]]></body>
       </method>
 
       <method name="addItem">
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -590,21 +590,21 @@
                     case "title":
                         // return title, or "Untitled" if empty/null
                         if (task.title) {
                             return task.title.replace(/\n/g, " ");
                         } else {
                             return cal.l10n.getCalString("eventUntitled");
                         }
                     case "entryDate":
-                        return task.recurrenceInfo ? cal.calGetString("dateFormat", "Repeating") : this._formatDateTime(task.entryDate);
+                        return task.recurrenceInfo ? cal.l10n.getDateFmtString("Repeating") : this._formatDateTime(task.entryDate);
                     case "dueDate":
-                        return task.recurrenceInfo ? cal.calGetString("dateFormat", "Repeating") : this._formatDateTime(task.dueDate);
+                        return task.recurrenceInfo ? cal.l10n.getDateFmtString("Repeating") : this._formatDateTime(task.dueDate);
                     case "completedDate":
-                        return task.recurrenceInfo ? cal.calGetString("dateFormat", "Repeating") : this._formatDateTime(task.completedDate);
+                        return task.recurrenceInfo ? cal.l10n.getDateFmtString("Repeating") : this._formatDateTime(task.completedDate);
                     case "percentComplete":
                         return (task.percentComplete > 0 ? task.percentComplete + "%" : "");
                     case "categories":
                         return task.getCategories({}).join(", "); // TODO l10n-unfriendly
                     case "location":
                         return task.getProperty("LOCATION");
                     case "status":
                         return getToDoStatusString(task);
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -317,17 +317,17 @@ var TodayPane = {
     /**
      * Shows short weekday names in the weekdayNameContainer
      */
     setShortWeekdays: function() {
         let weekdisplaydeck = document.getElementById("weekdayNameContainer");
         let childNodes = weekdisplaydeck.childNodes;
 
         for (let i = 0; i < childNodes.length; i++) {
-            childNodes[i].setAttribute("value", cal.calGetString("dateFormat", "day." + (i+1) + ".Mmm"));
+            childNodes[i].setAttribute("value", cal.l10n.getDateFmtString(`day.${i + 1}.Mmm`));
         }
     },
 
     /**
      * Sets the shown date from a JSDate.
      *
      * @param aNewDate      The date to show.
      */
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -239,17 +239,17 @@
     <implementation>
       <constructor><![CDATA[
           ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           this.setUpTodayDate();
       ]]></constructor>
 
       <method name="setUpTodayDate">
         <body><![CDATA[
-            let dayNumber = cal.calGetString("dateFormat", "day." + cal.dtz.now().day + ".number");
+            let dayNumber = cal.l10n.getDateFmtString(`day.${cal.dtz.now().day}.number`);
             document.getAnonymousElementByAttribute(this, "anonid", "day-label").value = dayNumber;
         ]]></body>
       </method>
     </implementation>
    </binding>
 
   <!-- this binding directly extends to a checkbox but is visualized as
        a treenode in a treecontrol-->
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -753,18 +753,17 @@
             let longDayList = new Array(7);
             let tempDate = new Date();
             let i, j;
             let useOSFormat;
             tempDate.setDate(tempDate.getDate() - (tempDate.getDay() - this.weekStart));
             for (i = 0; i < 7; i++) {
                 // if available, use UILocale days, else operating system format
                 try {
-                    dayList[i] = cal.calGetString("dateFormat",
-                                 "day." + (tempDate.getDay() + 1) + ".short");
+                    dayList[i] = cal.l10n.getDateFmtString(`day.${tempDate.getDay() + 1}.short`);
                 } catch (e) {
                     dayList[i] = tempDate.toLocaleDateString(undefined, { weekday: "short" });
                     useOSFormat = true;
                 }
                 longDayList[i] = tempDate.toLocaleDateString(undefined, { weekday: "long" });
                 tempDate.setDate(tempDate.getDate() + 1);
             }
 
@@ -863,18 +862,17 @@
             // Update the calendar
             let calbox = document.getAnonymousElementByAttribute(this, "anonid", "minimonth-calendar");
             let date = this._getStartDate(aDate);
 
             // 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"));
+                calbox.setAttribute("aria-label", cal.l10n.getDateFmtString(`month.${aDate.getMonth() + 1}.name`));
             } else {
                 let monthName = cal.l10n.formatMonth(aDate.getMonth() + 1,
                                                      "calendar", "monthInYear");
                 let label = cal.l10n.getCalString(
                     "monthInYear",
                     [monthName, aDate.getFullYear()]
                 );
                 calbox.setAttribute("aria-label", label);
--- a/calendar/import-export/calMonthGridPrinter.js
+++ b/calendar/import-export/calMonthGridPrinter.js
@@ -157,18 +157,18 @@ calMonthPrinter.prototype = {
         let monthName = cal.l10n.formatMonth(startOfMonth.month + 1, "calendar", "monthInYear");
         let monthTitle = cal.l10n.getCalString("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");
-            dayTitle.textContent = cal.calGetString("dateFormat", "day." + dayNumber + ".Mmm");
+            let dayTitle = currentMonth.querySelector(`.day${i}-title`);
+            dayTitle.textContent = cal.l10n.getDateFmtString(`day.${dayNumber}.Mmm`);
         }
 
         // Set up each week
         let weekInfoService = cal.getWeekInfoService();
         let endOfMonthView = weekInfoService.getEndOfWeek(startOfMonth.endOfMonth);
         let startOfMonthView = weekInfoService.getStartOfWeek(startOfMonth);
         let mainMonth = startOfMonth.month;
         let weekContainer = currentMonth.querySelector(".week-container");
--- a/calendar/resources/content/datetimepickers/datetimepickers.xml
+++ b/calendar/resources/content/datetimepickers/datetimepickers.xml
@@ -63,22 +63,22 @@
           let goButton = document.getAnonymousElementByAttribute(this, "anonid", "date-go-button");
           goButton.setAttribute("label", cal.l10n.getCalString("go"));
           // Load the stuff we're going to use to parse written dates
           this.mRelativeDates = [
               { word: cal.l10n.getCalString("today").toLowerCase(), offset: 0 },
               { word: cal.l10n.getCalString("yesterday").toLowerCase(), offset: -1 },
               { word: cal.l10n.getCalString("tomorrow").toLowerCase(), offset: 1 }];
           for (let i = 1; i <= 7; i++) {
-              this.mDayNames.push(cal.calGetString("dateFormat", "day." + i + ".name").toLowerCase());
+              this.mDayNames.push(cal.l10n.getDateFmtString(`day.${i}.name`).toLowerCase());
           }
 
           for (let i = 1; i <= 12; i++) {
-              this.mMonthLongNames.push(cal.calGetString("dateFormat", "month." + i + ".name").toLowerCase());
-              this.mMonthShortNames.push(cal.calGetString("dateFormat", "month." + i + ".Mmm").toLowerCase());
+              this.mMonthLongNames.push(cal.l10n.getDateFmtString(`month.${i}.name`).toLowerCase());
+              this.mMonthShortNames.push(cal.l10n.getDateFmtString(`month.${i}.Mmm`).toLowerCase());
           }
 
           // note that some languages have different conjugations of
           // next/last depending on the day
           this.mRelationWords = [
               { word: cal.l10n.getCalString("last1"), offset: -1 },
               { word: cal.l10n.getCalString("last2"), offset: -1 },
               { word: cal.l10n.getCalString("next1"), offset: 0 },
@@ -1601,22 +1601,22 @@
            noon before/after     "\u5348\u524d02:34"    "\u5348\u5f8c 02 34"
       -->
       <method name="parseTime">
         <parameter name="aValue"/>
         <body><![CDATA[
             let now = new Date();
 
             try {
-                let noon = cal.calGetString("dateFormat", "noon");
+                let noon = cal.l10n.getDateFmtString("noon");
                 if (aValue.toLowerCase() == noon.toLowerCase()) {
                     return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 12, 0, 0, 0);
                 }
 
-                let midnight = cal.calGetString("dateFormat", "midnight");
+                let midnight = cal.l10n.getDateFmtString("midnight");
                 if (aValue.toLowerCase() == midnight.toLowerCase()) {
                     return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
                 }
             } catch (ex) {
                 // Try/catch this, since some people are apparently
                 // interested in using the datepicker in remote apps, where
                 // calGetString wouldn't exist
             }
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
@@ -118,21 +118,21 @@ function setRecurrence(recurrence) {
         eid: recid,
     } = helpersForController(recurrence);
 
     // weekly
     recurrence.waitForElement(recid("period-list"));
     menulistSelect(recid("period-list"), "1", recurrence);
     recsleep();
 
-    let mon = cal.calGetString("dateFormat", "day.2.Mmm");
-    let tue = cal.calGetString("dateFormat", "day.3.Mmm");
-    let wed = cal.calGetString("dateFormat", "day.4.Mmm");
-    let thu = cal.calGetString("dateFormat", "day.5.Mmm");
-    let sat = cal.calGetString("dateFormat", "day.7.Mmm");
+    let mon = cal.l10n.getDateFmtString("day.2.Mmm");
+    let tue = cal.l10n.getDateFmtString("day.3.Mmm");
+    let wed = cal.l10n.getDateFmtString("day.4.Mmm");
+    let thu = cal.l10n.getDateFmtString("day.5.Mmm");
+    let sat = cal.l10n.getDateFmtString("day.7.Mmm");
 
     // starting from Monday so it should be checked. We have to wait a little,
     // because the checkedstate is set in background by JS.
     recurrence.waitFor(() => {
         return recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${mon}"}`));
     }, 30000);
     // check Tuesday, Wednesday, Thursday and Saturday too
     recurrence.click(reclookup(`${REC_DLG_DAYS}/{"label":"${tue}"}`));
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
@@ -142,19 +142,19 @@ function testWeeklyUntilRecurrence() {
 function setRecurrence(recurrence) {
     let { sleep: recsleep, lookup: reclookup, eid: recid } =
         helpersForController(recurrence);
 
     // weekly
     recurrence.waitForElement(recid("period-list"));
     menulistSelect(recid("period-list"), "1", recurrence);
 
-    let mon = cal.calGetString("dateFormat", "day.2.Mmm");
-    let wed = cal.calGetString("dateFormat", "day.4.Mmm");
-    let fri = cal.calGetString("dateFormat", "day.6.Mmm");
+    let mon = cal.l10n.getDateFmtString("day.2.Mmm");
+    let wed = cal.l10n.getDateFmtString("day.4.Mmm");
+    let fri = cal.l10n.getDateFmtString("day.6.Mmm");
 
     // starting from Monday so it should be checked. We have to wait a little,
     // because the checkedstate is set in background by JS.
     recurrence.waitFor(() => {
         return recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${mon}"}`));
     }, 30000);
     // starting from Monday so it should be checked
     recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${mon}"}`));
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
@@ -206,19 +206,19 @@ function testWeeklyWithExceptionRecurren
 }
 
 function setRecurrence(recurrence) {
     let { lookup: reclookup, eid: recid } = helpersForController(recurrence);
 
     // weekly
     menulistSelect(recid("period-list"), "1", recurrence);
 
-    let mon = cal.calGetString("dateFormat", "day.2.Mmm");
-    let wed = cal.calGetString("dateFormat", "day.4.Mmm");
-    let fri = cal.calGetString("dateFormat", "day.6.Mmm");
+    let mon = cal.l10n.getDateFmtString("day.2.Mmm");
+    let wed = cal.l10n.getDateFmtString("day.4.Mmm");
+    let fri = cal.l10n.getDateFmtString("day.6.Mmm");
 
     // starting from Monday so it should be checked. We have to wait a little,
     // because the checkedstate is set in background by JS.
     recurrence.waitFor(() => {
         return recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${mon}"}`));
     }, 10000);
     // check Wednesday and Friday too
     recurrence.click(reclookup(`${REC_DLG_DAYS}/{"label":"${wed}"}`));
@@ -231,20 +231,20 @@ function setRecurrence(recurrence) {
 }
 
 function changeRecurrence(recurrence) {
     let { lookup: reclookup, eid: recid } = helpersForController(recurrence);
 
     // weekly
     menulistSelect(recid("period-list"), "1", recurrence);
 
-    let mon = cal.calGetString("dateFormat", "day.2.Mmm");
-    let tue = cal.calGetString("dateFormat", "day.3.Mmm");
-    let wed = cal.calGetString("dateFormat", "day.4.Mmm");
-    let fri = cal.calGetString("dateFormat", "day.6.Mmm");
+    let mon = cal.l10n.getDateFmtString("day.2.Mmm");
+    let tue = cal.l10n.getDateFmtString("day.3.Mmm");
+    let wed = cal.l10n.getDateFmtString("day.4.Mmm");
+    let fri = cal.l10n.getDateFmtString("day.6.Mmm");
 
     // check old rule
     // starting from Monday so it should be checked. We have to wait a little,
     // because the checkedstate is set in background by JS.
     recurrence.waitFor(() => {
         return recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${mon}"}`));
     }, 10000);
     recurrence.assertChecked(reclookup(`${REC_DLG_DAYS}/{"label":"${wed}"}`));