Bug 1639515 - Part 3: Port mozIntl.getDisplayNames users to mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum

Update callers to the previous `mozIntl.getDisplayNames` function to use
`mozIntl.DisplayNames`.

Differential Revision: https://phabricator.services.mozilla.com/D76115
This commit is contained in:
André Bargull 2021-09-14 09:20:32 +00:00
Родитель 5680bb810a
Коммит 57f47703d6
2 изменённых файлов: 43 добавлений и 49 удалений

Просмотреть файл

@ -390,20 +390,14 @@ class AboutProtectionsParent extends JSWindowActorParent {
break;
case "FetchContentBlockingEvents":
let dataToSend = {};
let weekdays = Services.intl.getDisplayNamesDeprecated(undefined, {
style: "short",
keys: [
"dates/gregorian/weekdays/sunday",
"dates/gregorian/weekdays/monday",
"dates/gregorian/weekdays/tuesday",
"dates/gregorian/weekdays/wednesday",
"dates/gregorian/weekdays/thursday",
"dates/gregorian/weekdays/friday",
"dates/gregorian/weekdays/saturday",
"dates/gregorian/weekdays/sunday",
],
let displayNames = new Services.intl.DisplayNames(undefined, {
type: "weekday",
style: "abbreviated",
calendar: "gregory",
});
weekdays = Object.values(weekdays.values);
// Weekdays starting Sunday (7) to Saturday (6).
let weekdays = [7, 1, 2, 3, 4, 5, 6].map(day => displayNames.of(day));
dataToSend.weekdays = weekdays;
if (PrivateBrowsingUtils.isWindowPrivate(win)) {

Просмотреть файл

@ -147,37 +147,42 @@ var DateTimePickerPanel = class {
case "date": {
const { year, month, day } = detail.value;
const { firstDayOfWeek, weekends } = this.getCalendarInfo(locale);
const monthStrings = this.getDisplayNames(
locale,
[
"dates/gregorian/months/january",
"dates/gregorian/months/february",
"dates/gregorian/months/march",
"dates/gregorian/months/april",
"dates/gregorian/months/may",
"dates/gregorian/months/june",
"dates/gregorian/months/july",
"dates/gregorian/months/august",
"dates/gregorian/months/september",
"dates/gregorian/months/october",
"dates/gregorian/months/november",
"dates/gregorian/months/december",
],
"short"
);
const weekdayStrings = this.getDisplayNames(
locale,
[
"dates/gregorian/weekdays/sunday",
"dates/gregorian/weekdays/monday",
"dates/gregorian/weekdays/tuesday",
"dates/gregorian/weekdays/wednesday",
"dates/gregorian/weekdays/thursday",
"dates/gregorian/weekdays/friday",
"dates/gregorian/weekdays/saturday",
],
"short"
);
const monthDisplayNames = new Services.intl.DisplayNames(locale, {
type: "month",
style: "short",
calendar: "gregory",
});
const monthStrings = [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
].map(month => monthDisplayNames.of(month));
const weekdayDisplayNames = new Services.intl.DisplayNames(locale, {
type: "weekday",
style: "abbreviated",
calendar: "gregory",
});
const weekdayStrings = [
// Weekdays starting Sunday (7) to Saturday (6).
7,
1,
2,
3,
4,
5,
6,
].map(weekday => weekdayDisplayNames.of(weekday));
this.postMessageToPicker({
name: "PickerInit",
@ -292,11 +297,6 @@ var DateTimePickerPanel = class {
};
}
getDisplayNames(locale, keys, style) {
const displayNames = Services.intl.getDisplayNamesDeprecated(locale, { keys, style });
return keys.map(key => displayNames.values[key]);
}
handleEvent(aEvent) {
switch (aEvent.type) {
case "load": {