mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
fix(i18n): форматировать даты и числа локалью выбранного языка, а не браузера
This commit is contained in:
@@ -11,6 +11,7 @@ export function formatUptime(seconds: number): string {
|
||||
|
||||
import i18next from 'i18next';
|
||||
import { currencyApi, type ExchangeRates } from '../api/currency';
|
||||
import { uiLocale } from './uiLocale';
|
||||
|
||||
const LANG_CURRENCY_MAP: Record<
|
||||
string,
|
||||
@@ -60,18 +61,10 @@ export function formatPrice(kopeks: number, lang?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
const SHORT_DATE_LOCALE_MAP: Record<string, string> = {
|
||||
ru: 'ru-RU',
|
||||
en: 'en-US',
|
||||
zh: 'zh-CN',
|
||||
fa: 'fa-IR',
|
||||
};
|
||||
|
||||
/** Date-only (dd.mm.yyyy) in the active UI locale; '-' for a null date. */
|
||||
export function formatShortDate(date: string | null): string {
|
||||
if (!date) return '-';
|
||||
const locale = SHORT_DATE_LOCALE_MAP[i18next.language] || 'ru-RU';
|
||||
return new Date(date).toLocaleDateString(locale, {
|
||||
return new Date(date).toLocaleDateString(uiLocale(), {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
|
||||
Reference in New Issue
Block a user