|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
import dayjs from 'dayjs' |
|
|
|
|
import i18n from 'i18next' |
|
|
|
|
import i18n, { Resource } from 'i18next' |
|
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector' |
|
|
|
|
import { initReactI18next } from 'react-i18next' |
|
|
|
|
import ar from './locales/ar' |
|
|
|
|
@ -13,32 +13,29 @@ import pt from './locales/pt'
@@ -13,32 +13,29 @@ import pt from './locales/pt'
|
|
|
|
|
import ru from './locales/ru' |
|
|
|
|
import zh from './locales/zh' |
|
|
|
|
|
|
|
|
|
export const LocalizedLanguageNames = { |
|
|
|
|
en: 'English', |
|
|
|
|
zh: '简体中文', |
|
|
|
|
pl: 'Polski', |
|
|
|
|
es: 'Español', |
|
|
|
|
fr: 'Français', |
|
|
|
|
de: 'Deutsch', |
|
|
|
|
ja: '日本語', |
|
|
|
|
ru: 'Русский', |
|
|
|
|
pt: 'Português', |
|
|
|
|
ar: 'العربية' |
|
|
|
|
} |
|
|
|
|
const languages = { |
|
|
|
|
en: { resource: en, name: 'English' }, |
|
|
|
|
zh: { resource: zh, name: '简体中文' }, |
|
|
|
|
pl: { resource: pl, name: 'Polski' }, |
|
|
|
|
es: { resource: es, name: 'Español' }, |
|
|
|
|
fr: { resource: fr, name: 'Français' }, |
|
|
|
|
de: { resource: de, name: 'Deutsch' }, |
|
|
|
|
ja: { resource: ja, name: '日本語' }, |
|
|
|
|
ru: { resource: ru, name: 'Русский' }, |
|
|
|
|
pt: { resource: pt, name: 'Português' }, |
|
|
|
|
ar: { resource: ar, name: 'العربية' } |
|
|
|
|
} as const |
|
|
|
|
|
|
|
|
|
const resources = { |
|
|
|
|
en, |
|
|
|
|
zh, |
|
|
|
|
pl, |
|
|
|
|
es, |
|
|
|
|
fr, |
|
|
|
|
de, |
|
|
|
|
ja, |
|
|
|
|
ru, |
|
|
|
|
pt, |
|
|
|
|
ar |
|
|
|
|
export type TLanguage = keyof typeof languages |
|
|
|
|
export const LocalizedLanguageNames: { [key in TLanguage]?: string } = {} |
|
|
|
|
const resources: { [key in TLanguage]?: Resource } = {} |
|
|
|
|
const supportedLanguages: TLanguage[] = [] |
|
|
|
|
for (const [key, value] of Object.entries(languages)) { |
|
|
|
|
const lang = key as TLanguage |
|
|
|
|
LocalizedLanguageNames[lang] = value.name |
|
|
|
|
resources[lang] = value.resource |
|
|
|
|
supportedLanguages.push(lang) |
|
|
|
|
} |
|
|
|
|
const supportedLanguages = Object.keys(resources) |
|
|
|
|
|
|
|
|
|
i18n |
|
|
|
|
.use(LanguageDetector) |
|
|
|
|
@ -58,34 +55,22 @@ i18n
@@ -58,34 +55,22 @@ i18n
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
i18n.services.formatter?.add('date', (timestamp, lng) => { |
|
|
|
|
if (lng?.startsWith('zh')) { |
|
|
|
|
return dayjs(timestamp).format('YYYY年MM月DD日') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('pl')) { |
|
|
|
|
return dayjs(timestamp).format('DD.MM.YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('ja')) { |
|
|
|
|
return dayjs(timestamp).format('YYYY年MM月DD日') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('de')) { |
|
|
|
|
return dayjs(timestamp).format('DD.MM.YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('ru')) { |
|
|
|
|
return dayjs(timestamp).format('DD.MM.YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('es')) { |
|
|
|
|
return dayjs(timestamp).format('DD/MM/YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('fr')) { |
|
|
|
|
return dayjs(timestamp).format('DD/MM/YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('pt')) { |
|
|
|
|
return dayjs(timestamp).format('DD/MM/YYYY') |
|
|
|
|
} |
|
|
|
|
if (lng?.startsWith('ar')) { |
|
|
|
|
return dayjs(timestamp).format('DD/MM/YYYY') |
|
|
|
|
switch (lng) { |
|
|
|
|
case 'zh': |
|
|
|
|
case 'ja': |
|
|
|
|
return dayjs(timestamp).format('YYYY年MM月DD日') |
|
|
|
|
case 'pl': |
|
|
|
|
case 'de': |
|
|
|
|
case 'ru': |
|
|
|
|
return dayjs(timestamp).format('DD.MM.YYYY') |
|
|
|
|
case 'es': |
|
|
|
|
case 'fr': |
|
|
|
|
case 'pt': |
|
|
|
|
case 'ar': |
|
|
|
|
return dayjs(timestamp).format('DD/MM/YYYY') |
|
|
|
|
default: |
|
|
|
|
return dayjs(timestamp).format('MMM D, YYYY') |
|
|
|
|
} |
|
|
|
|
return dayjs(timestamp).format('MMM D, YYYY') |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
export default i18n |
|
|
|
|
|