mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-06 04:49:52 +01:00
Calendar: Fix localization (#1310)
This commit is contained in:
parent
8996446a04
commit
c2abfa48c3
@ -3,10 +3,7 @@ import React, {
|
|||||||
} from '../../lib/teact/teact';
|
} from '../../lib/teact/teact';
|
||||||
|
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import {
|
import { formatTime, formatDateToString } from '../../util/dateFormat';
|
||||||
formatMonthAndYear, formatHumanDate, formatTime,
|
|
||||||
} from '../../util/dateFormat';
|
|
||||||
import { IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment';
|
|
||||||
import useLang, { LangFn } from '../../hooks/useLang';
|
import useLang, { LangFn } from '../../hooks/useLang';
|
||||||
|
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
@ -28,7 +25,15 @@ export type OwnProps = {
|
|||||||
onSecondButtonClick?: NoneToVoidFunction;
|
onSecondButtonClick?: NoneToVoidFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WEEKDAY_LETTERS = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
const WEEKDAY_LETTERS = [
|
||||||
|
'lng_weekday1',
|
||||||
|
'lng_weekday2',
|
||||||
|
'lng_weekday3',
|
||||||
|
'lng_weekday4',
|
||||||
|
'lng_weekday5',
|
||||||
|
'lng_weekday6',
|
||||||
|
'lng_weekday7',
|
||||||
|
];
|
||||||
|
|
||||||
const CalendarModal: FC<OwnProps> = ({
|
const CalendarModal: FC<OwnProps> = ({
|
||||||
selectedAt,
|
selectedAt,
|
||||||
@ -183,7 +188,9 @@ const CalendarModal: FC<OwnProps> = ({
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
{formatMonthAndYear(lang, selectedDate, IS_SINGLE_COLUMN_LAYOUT)}
|
{lang(`lng_month${selectedDate.getMonth() + 1}`)}
|
||||||
|
{' '}
|
||||||
|
{selectedDate.getFullYear()}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -210,9 +217,9 @@ const CalendarModal: FC<OwnProps> = ({
|
|||||||
|
|
||||||
<div className="calendar-wrapper">
|
<div className="calendar-wrapper">
|
||||||
<div className="calendar-grid">
|
<div className="calendar-grid">
|
||||||
{WEEKDAY_LETTERS.map((letter) => (
|
{WEEKDAY_LETTERS.map((day) => (
|
||||||
<div className="day-button faded weekday">
|
<div className="day-button faded weekday">
|
||||||
<span>{letter}</span>
|
<span>{lang(day)}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{calendarGrid.map((gridDate) => (
|
{calendarGrid.map((gridDate) => (
|
||||||
@ -296,13 +303,14 @@ function formatInputTime(value: string | number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatSubmitLabel(lang: LangFn, date: Date) {
|
function formatSubmitLabel(lang: LangFn, date: Date) {
|
||||||
const day = formatHumanDate(lang, date, true);
|
const day = formatDateToString(date, lang.code);
|
||||||
|
const today = formatDateToString(new Date(), lang.code);
|
||||||
|
|
||||||
if (day === 'Today') {
|
if (day === today) {
|
||||||
return lang('Conversation.ScheduleMessage.SendToday', formatTime(date));
|
return lang('Conversation.ScheduleMessage.SendToday', formatTime(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
return lang('Conversation.ScheduleMessage.SendOn', day).replace('%@', formatTime(date));
|
return lang('Conversation.ScheduleMessage.SendOn', [day, formatTime(date)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(CalendarModal);
|
export default memo(CalendarModal);
|
||||||
|
Loading…
Reference in New Issue
Block a user