mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-02 17:48:34 +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';
|
||||
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import {
|
||||
formatMonthAndYear, formatHumanDate, formatTime,
|
||||
} from '../../util/dateFormat';
|
||||
import { IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment';
|
||||
import { formatTime, formatDateToString } from '../../util/dateFormat';
|
||||
import useLang, { LangFn } from '../../hooks/useLang';
|
||||
|
||||
import Modal from '../ui/Modal';
|
||||
@ -28,7 +25,15 @@ export type OwnProps = {
|
||||
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> = ({
|
||||
selectedAt,
|
||||
@ -183,7 +188,9 @@ const CalendarModal: FC<OwnProps> = ({
|
||||
</Button>
|
||||
|
||||
<h4>
|
||||
{formatMonthAndYear(lang, selectedDate, IS_SINGLE_COLUMN_LAYOUT)}
|
||||
{lang(`lng_month${selectedDate.getMonth() + 1}`)}
|
||||
{' '}
|
||||
{selectedDate.getFullYear()}
|
||||
</h4>
|
||||
|
||||
<Button
|
||||
@ -210,9 +217,9 @@ const CalendarModal: FC<OwnProps> = ({
|
||||
|
||||
<div className="calendar-wrapper">
|
||||
<div className="calendar-grid">
|
||||
{WEEKDAY_LETTERS.map((letter) => (
|
||||
{WEEKDAY_LETTERS.map((day) => (
|
||||
<div className="day-button faded weekday">
|
||||
<span>{letter}</span>
|
||||
<span>{lang(day)}</span>
|
||||
</div>
|
||||
))}
|
||||
{calendarGrid.map((gridDate) => (
|
||||
@ -296,13 +303,14 @@ function formatInputTime(value: string | number) {
|
||||
}
|
||||
|
||||
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.SendOn', day).replace('%@', formatTime(date));
|
||||
return lang('Conversation.ScheduleMessage.SendOn', [day, formatTime(date)]);
|
||||
}
|
||||
|
||||
export default memo(CalendarModal);
|
||||
|
Loading…
Reference in New Issue
Block a user