From c2f018c39fadbdb2bd402bce7f890c2834fb0204 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Wed, 19 May 2021 13:24:37 +0200 Subject: [PATCH] calendar translation / localization new strings incl. decoration bindings for the moment.js based localizer. correction of sort-order based on moment.js format order (streamlining decorator and json). enables translation for the following formats: - dateFormat - dayFormat - yearMonthDateFormat (from dayFormat for year-view, incl. NaN display fixes) - weekOfYearFormat (in preparation of week-view) - agendaDateFormat (in preparation of agenda-view) --- public/locale/de/calendar.json | 9 +++++++-- public/locale/en/calendar.json | 9 +++++++-- public/locale/fr/calendar.json | 9 +++++++-- public/locale/zh_CN/calendar.json | 9 +++++++-- .../grid-views/year-widgets/YearDay.js | 4 ++-- src/locale/lang/de.js | 9 +++++++-- src/locale/lang/en.js | 9 +++++++-- src/locale/lang/fr.js | 9 +++++++-- src/locale/lang/zh_CN.js | 9 +++++++-- src/utils/localizers/intl-decorator.js | 16 +++++++++++++--- 10 files changed, 71 insertions(+), 21 deletions(-) diff --git a/public/locale/de/calendar.json b/public/locale/de/calendar.json index e2bd799..95c767d 100644 --- a/public/locale/de/calendar.json +++ b/public/locale/de/calendar.json @@ -7,11 +7,16 @@ "Color_From": "Farbe", "Unnamed_record": "Neuer Eintrag", "more": "mehr", + ".rbc.localizer.moment.dateFormat": "DD", + ".rbc.localizer.moment.dayFormat": "DD ddd", + ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.monthFormat": "MMMM", ".rbc.localizer.moment.yearHeaderFormat": "YYYY", ".rbc.localizer.moment.dayHeaderFormat": "dddd, DD. MMMM", - ".rbc.localizer.moment.monthFormat": "MMMM", - ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.agendaDateFormat": "ddd MMM DD", ".rbc.localizer.moment.yearMonthWeekdayFormat": "ddd", + ".rbc.localizer.moment.yearMonthDateFormat": "DD", + ".rbc.localizer.moment.weekOfYearFormat": "WW", ".rbc.messages.date": "Datum", ".rbc.messages.time": "Zeit", ".rbc.messages.event": "Ereignis", diff --git a/public/locale/en/calendar.json b/public/locale/en/calendar.json index 66cc02a..24be39e 100644 --- a/public/locale/en/calendar.json +++ b/public/locale/en/calendar.json @@ -7,11 +7,16 @@ "Color_From": "Color field", "Unnamed_record": "Unnamed record", "more": "more", + ".rbc.localizer.moment.dateFormat": "DD", + ".rbc.localizer.moment.dayFormat": "DD ddd", + ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.monthFormat": "MMM", ".rbc.localizer.moment.yearHeaderFormat": "YYYY", ".rbc.localizer.moment.dayHeaderFormat": "MM-dd-DD", - ".rbc.localizer.moment.monthFormat": "MMM", - ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.agendaDateFormat": "ddd MMM DD", ".rbc.localizer.moment.yearMonthWeekdayFormat": "dd", + ".rbc.localizer.moment.yearMonthDateFormat": "DD", + ".rbc.localizer.moment.weekOfYearFormat": "WW", ".rbc.messages.date": "Date", ".rbc.messages.time": "Time", ".rbc.messages.event": "Event", diff --git a/public/locale/fr/calendar.json b/public/locale/fr/calendar.json index 5c6887b..95de689 100644 --- a/public/locale/fr/calendar.json +++ b/public/locale/fr/calendar.json @@ -7,11 +7,16 @@ "Color_From": "Couleur", "Unnamed_record": "Nouveau enregistrement", "more": "Plus", + ".rbc.localizer.moment.dateFormat": "DD", + ".rbc.localizer.moment.dayFormat": "DD ddd", + ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.monthFormat": "MMM", ".rbc.localizer.moment.yearHeaderFormat": "YYYY", ".rbc.localizer.moment.dayHeaderFormat": "ddd MMM DD", - ".rbc.localizer.moment.monthFormat": "MMM", - ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.agendaDateFormat": "ddd MMM DD", ".rbc.localizer.moment.yearMonthWeekdayFormat": "dd", + ".rbc.localizer.moment.yearMonthDateFormat": "DD", + ".rbc.localizer.moment.weekOfYearFormat": "WW", ".rbc.messages.date": "Date", ".rbc.messages.time": "Heure", ".rbc.messages.event": "Evénement", diff --git a/public/locale/zh_CN/calendar.json b/public/locale/zh_CN/calendar.json index 09451f8..142abf7 100644 --- a/public/locale/zh_CN/calendar.json +++ b/public/locale/zh_CN/calendar.json @@ -7,11 +7,16 @@ "Color_From": "颜色字段", "Unnamed_record": "未命名记录", "more": "更多", + ".rbc.localizer.moment.dateFormat": "DD", + ".rbc.localizer.moment.dayFormat": "DD ddd", + ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.monthFormat": "MMM", ".rbc.localizer.moment.yearHeaderFormat": "YYYY年", ".rbc.localizer.moment.dayHeaderFormat": "MMMDD日 星期dd", - ".rbc.localizer.moment.monthFormat": "MMM", - ".rbc.localizer.moment.weekdayFormat": "ddd", + ".rbc.localizer.moment.agendaDateFormat": "ddd MMM DD", ".rbc.localizer.moment.yearMonthWeekdayFormat": "dd", + ".rbc.localizer.moment.yearMonthDateFormat": "DD", + ".rbc.localizer.moment.weekOfYearFormat": "WW", ".rbc.messages.date": "Date", ".rbc.messages.time": "Time", ".rbc.messages.event": "Event", diff --git a/src/components/grid-views/year-widgets/YearDay.js b/src/components/grid-views/year-widgets/YearDay.js index 6da8b2f..a5e2dbd 100755 --- a/src/components/grid-views/year-widgets/YearDay.js +++ b/src/components/grid-views/year-widgets/YearDay.js @@ -35,12 +35,12 @@ class YearDay extends React.Component { let { isShowEvents } = this.state; let isOffRange = dates.month(day) !== dates.month(monthDate); let isCurrentDay = dates.eq(day, new Date(), 'day'); - let label = localizer.format(day, 'dateFormat'); + let label = localizer.format(day, 'yearMonthDateFormat'); return (
this.rbcYearDayItem = ref}>
-
{Number(label)}
+
{label}
{dayEvents.length > 0 && } {isShowEvents && diff --git a/src/locale/lang/de.js b/src/locale/lang/de.js index 06d70ac..700328b 100644 --- a/src/locale/lang/de.js +++ b/src/locale/lang/de.js @@ -7,11 +7,16 @@ const de = { 'Color_From': 'Farbe', 'Unnamed_record': 'Neuer Eintrag', 'more': 'mehr', + '.rbc.localizer.moment.dateFormat': 'DD', + '.rbc.localizer.moment.dayFormat': 'DD ddd', + '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.monthFormat': 'MMMM', '.rbc.localizer.moment.yearHeaderFormat': 'YYYY', '.rbc.localizer.moment.dayHeaderFormat': 'dddd, DD. MMMM', - '.rbc.localizer.moment.monthFormat': 'MMMM', - '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.agendaDateFormat': 'ddd MMM DD', '.rbc.localizer.moment.yearMonthWeekdayFormat': 'ddd', + '.rbc.localizer.moment.yearMonthDateFormat': 'DD', + '.rbc.localizer.moment.weekOfYearFormat': 'WW', '.rbc.messages.date': 'Datum', '.rbc.messages.time': 'Zeit', '.rbc.messages.event': 'Ereignis', diff --git a/src/locale/lang/en.js b/src/locale/lang/en.js index 85c387c..fa7fa6a 100644 --- a/src/locale/lang/en.js +++ b/src/locale/lang/en.js @@ -7,11 +7,16 @@ const en = { 'Color_From': 'Color field', 'Unnamed_record': 'Unnamed record', 'more': 'more', + '.rbc.localizer.moment.dateFormat': 'DD', + '.rbc.localizer.moment.dayFormat': 'DD ddd', + '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.monthFormat': 'MMM', '.rbc.localizer.moment.yearHeaderFormat': 'YYYY', '.rbc.localizer.moment.dayHeaderFormat': 'MM-dd-DD', - '.rbc.localizer.moment.monthFormat': 'MMM', - '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.agendaDateFormat': 'ddd MMM DD', '.rbc.localizer.moment.yearMonthWeekdayFormat': 'dd', + '.rbc.localizer.moment.yearMonthDateFormat': 'DD', + '.rbc.localizer.moment.weekOfYearFormat': 'WW', '.rbc.messages.date': 'Date', '.rbc.messages.time': 'Time', '.rbc.messages.event': 'Event', diff --git a/src/locale/lang/fr.js b/src/locale/lang/fr.js index 7b12a92..c310d8b 100644 --- a/src/locale/lang/fr.js +++ b/src/locale/lang/fr.js @@ -7,11 +7,16 @@ const fr = { 'Color_From': 'Couleur', 'Unnamed_record': 'Nouveau enregistrement', 'more': 'Plus', + '.rbc.localizer.moment.dateFormat': 'DD', + '.rbc.localizer.moment.dayFormat': 'DD ddd', + '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.monthFormat': 'MMM', '.rbc.localizer.moment.yearHeaderFormat': 'YYYY', '.rbc.localizer.moment.dayHeaderFormat': 'ddd MMM DD', - '.rbc.localizer.moment.monthFormat': 'MMM', - '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.agendaDateFormat': 'ddd MMM DD', '.rbc.localizer.moment.yearMonthWeekdayFormat': 'dd', + '.rbc.localizer.moment.yearMonthDateFormat': 'DD', + '.rbc.localizer.moment.weekOfYearFormat': 'WW', '.rbc.messages.date': 'Date', '.rbc.messages.time': 'Heure', '.rbc.messages.event': 'Evénement', diff --git a/src/locale/lang/zh_CN.js b/src/locale/lang/zh_CN.js index 66c5515..eaa5463 100644 --- a/src/locale/lang/zh_CN.js +++ b/src/locale/lang/zh_CN.js @@ -7,11 +7,16 @@ const zh_CN = { 'Color_From': '颜色字段', 'Unnamed_record': '未命名记录', 'more': '更多', + '.rbc.localizer.moment.dateFormat': 'DD', + '.rbc.localizer.moment.dayFormat': 'DD ddd', + '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.monthFormat': 'MMM', '.rbc.localizer.moment.yearHeaderFormat': 'YYYY年', '.rbc.localizer.moment.dayHeaderFormat': 'MMMDD日 星期dd', - '.rbc.localizer.moment.monthFormat': 'MMM', - '.rbc.localizer.moment.weekdayFormat': 'ddd', + '.rbc.localizer.moment.agendaDateFormat': 'ddd MMM DD', '.rbc.localizer.moment.yearMonthWeekdayFormat': 'dd', + '.rbc.localizer.moment.yearMonthDateFormat': 'DD', + '.rbc.localizer.moment.weekOfYearFormat': 'WW', '.rbc.messages.date': 'Date', '.rbc.messages.time': 'Time', '.rbc.messages.event': 'Event', diff --git a/src/utils/localizers/intl-decorator.js b/src/utils/localizers/intl-decorator.js index 75c6ca4..981c80c 100644 --- a/src/utils/localizers/intl-decorator.js +++ b/src/utils/localizers/intl-decorator.js @@ -53,11 +53,21 @@ const intlDayHeaderFormatDecorator = (subject, moment) => { date, intl.get(`.rbc.localizer.moment.${format}`).d(_formats[format]) ); }; - intlFormat('dayHeaderFormat'); - intlFormat('yearHeaderFormat'); + /* in moment.js order */ + intlFormat('dateFormat'); + intlFormat('dayFormat'); + intlFormat('weekdayFormat'); intlFormat('monthFormat'); + + intlFormat('yearHeaderFormat'); + intlFormat('dayHeaderFormat'); + + intlFormat('agendaDateFormat', 'ddd MMM DD'); + + /* additional decorator formats */ intlFormat('yearMonthWeekdayFormat', 'dd'); - intlFormat('weekdayFormat'); + intlFormat('yearMonthDateFormat', 'DD'); + intlFormat('weekOfYearFormat', 'WW'); subject.format = (value, format) => { return _format(value, format, intlLocaleCulture());