Bug 1727522 - Use the i10n api instead for chat log date formatting. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D126573

--HG--
extra : amend_source : 83940cb5c9953a636b2785cd8b7ed0a369510f9b
This commit is contained in:
Lasana Murray 2021-09-28 13:49:02 +03:00
Родитель c4e0d3cf67
Коммит d4ec87b48a
3 изменённых файлов: 10 добавлений и 92 удалений

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

@ -1,62 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
month.1.Mmm=Jan
month.2.Mmm=Feb
month.3.Mmm=Mar
month.4.Mmm=Apr
month.5.Mmm=May
month.6.Mmm=Jun
month.7.Mmm=Jul
month.8.Mmm=Aug
month.9.Mmm=Sep
month.10.Mmm=Oct
month.11.Mmm=Nov
month.12.Mmm=Dec
month.1.name=January
month.2.name=February
month.3.name=March
month.4.name=April
month.5.name=May
month.6.name=June
month.7.name=July
month.8.name=August
month.9.name=September
month.10.name=October
month.11.name=November
month.12.name=December
day.1.name=Sunday
day.2.name=Monday
day.3.name=Tuesday
day.4.name=Wednesday
day.5.name=Thursday
day.6.name=Friday
day.7.name=Saturday
day.1.Mmm=Sun
day.2.Mmm=Mon
day.3.Mmm=Tue
day.4.Mmm=Wed
day.5.Mmm=Thu
day.6.Mmm=Fri
day.7.Mmm=Sat
day.1.short=Su
day.2.short=Mo
day.3.short=Tu
day.4.short=We
day.5.short=Th
day.6.short=Fr
day.7.short=Sa
noon=Noon
midnight=Midnight
AllDay=All Day
# LOCALIZATION NOTE (finduri-MonthYear):
# %1$S is the month name, %2$S is the year (4 digits format).
finduri-MonthYear=%1$S %2$S

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

@ -12,7 +12,6 @@
locale/@AB_CD@/chat/commands.properties (%commands.properties)
locale/@AB_CD@/chat/contacts.properties (%contacts.properties)
locale/@AB_CD@/chat/conversations.properties (%conversations.properties)
locale/@AB_CD@/chat/dateFormat.properties (%dateFormat.properties)
locale/@AB_CD@/chat/facebook.properties (%facebook.properties)
locale/@AB_CD@/chat/irc.properties (%irc.properties)
locale/@AB_CD@/chat/logger.properties (%logger.properties)

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

@ -1857,35 +1857,16 @@ chatLogTreeView.prototype = {
}
this._rowMap = [];
// Used to show the dates in the log list in the locale of the application.
let dateFormatBundle = Services.strings.createBundle(
"chrome://chat/locale/dateFormat.properties"
);
let placesBundle = Services.strings.createBundle(
"chrome://places/locale/places.properties"
);
const dateFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "short",
let dateFormat = new Intl.DateTimeFormat(undefined, { dateStyle: "short" });
let monthYearFormat = new Intl.DateTimeFormat(undefined, {
year: "numeric",
month: "long",
});
let formatDate = function(aDate) {
return dateFormatter.format(aDate);
};
let formatMonthYear = function(aDate) {
let month = formatMonth(aDate);
return dateFormatBundle.formatStringFromName("finduri-MonthYear", [
month,
aDate.getFullYear(),
]);
};
let formatMonth = aDate =>
dateFormatBundle.GetStringFromName(
"month." + (aDate.getMonth() + 1) + ".name"
);
let formatWeekday = aDate =>
dateFormatBundle.GetStringFromName(
"day." + (aDate.getDay() + 1) + ".name"
);
let monthFormat = new Intl.DateTimeFormat(undefined, { month: "long" });
let weekdayFormat = new Intl.DateTimeFormat(undefined, { weekday: "long" });
let nowDate = new Date();
let todayDate = new Date(
nowDate.getFullYear(),
@ -1912,7 +1893,7 @@ chatLogTreeView.prototype = {
let logDate = new Date(log.time * 1000);
// Calculate elapsed time between the log and 00:00:00 today.
let timeFromToday = todayDate - logDate;
let title = formatDate(logDate);
let title = dateFormat.format(logDate);
let group;
if (timeFromToday <= 0) {
today = new chatLogTreeLogItem(
@ -1931,7 +1912,7 @@ chatLogTreeView.prototype = {
} else if (timeFromToday <= kWeekInMsecs - kDayInMsecs) {
// Note that the 7 days of the current week include today.
group = firstgroups.currentWeek;
title = formatWeekday(logDate);
title = weekdayFormat.format(logDate);
} else if (timeFromToday <= kTwoWeeksInMsecs - kDayInMsecs) {
group = firstgroups.previousWeek;
} else {
@ -1948,10 +1929,10 @@ chatLogTreeView.prototype = {
"finduri-AgeInMonths-is-0"
);
} else {
groupname = formatMonth(logDate);
groupname = monthFormat.format(logDate);
}
} else {
groupname = formatMonthYear(logDate);
groupname = monthYearFormat.format(logDate);
}
groups[groupID] = {
entries: [],