@@ -13,9 +13,9 @@ import {
|
||||
getCurrentDateTimeAsString,
|
||||
getCurrentTimeAsString,
|
||||
unicodeCLDRtoBCP47,
|
||||
dateLocale,
|
||||
} from "@shared/utils/date";
|
||||
import User from "~/models/User";
|
||||
import { dateLocale } from "~/utils/i18n";
|
||||
|
||||
export function dateToHeading(
|
||||
dateTime: string,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
import {
|
||||
de,
|
||||
enUS,
|
||||
es,
|
||||
faIR,
|
||||
fr,
|
||||
it,
|
||||
ja,
|
||||
ko,
|
||||
nl,
|
||||
ptBR,
|
||||
pt,
|
||||
pl,
|
||||
ru,
|
||||
tr,
|
||||
vi,
|
||||
zhCN,
|
||||
zhTW,
|
||||
} from "date-fns/locale";
|
||||
import i18n from "i18next";
|
||||
import backend from "i18next-http-backend";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
@@ -24,36 +5,6 @@ import { languages } from "@shared/i18n";
|
||||
import { unicodeCLDRtoBCP47, unicodeBCP47toCLDR } from "@shared/utils/date";
|
||||
import Logger from "./Logger";
|
||||
|
||||
const locales = {
|
||||
de_DE: de,
|
||||
en_US: enUS,
|
||||
es_ES: es,
|
||||
fa_IR: faIR,
|
||||
fr_FR: fr,
|
||||
it_IT: it,
|
||||
ja_JP: ja,
|
||||
ko_KR: ko,
|
||||
nl_NL: nl,
|
||||
pt_BR: ptBR,
|
||||
pt_PT: pt,
|
||||
pl_PL: pl,
|
||||
ru_RU: ru,
|
||||
tr_TR: tr,
|
||||
vi_VN: vi,
|
||||
zh_CN: zhCN,
|
||||
zh_TW: zhTW,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the date-fns locale object for the given user language preference.
|
||||
*
|
||||
* @param language The user language
|
||||
* @returns The date-fns locale.
|
||||
*/
|
||||
export function dateLocale(language: string | null | undefined) {
|
||||
return language ? locales[language] : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes i18n library, loading all available translations from the
|
||||
* API backend.
|
||||
@@ -94,5 +45,3 @@ export function initI18n(defaultLanguage = "en_US") {
|
||||
|
||||
return i18n;
|
||||
}
|
||||
|
||||
export { locales };
|
||||
|
||||
Reference in New Issue
Block a user