21 lines
512 B
TypeScript
21 lines
512 B
TypeScript
import { useI18nStore } from './store';
|
|
import type { Locale } from './runtime';
|
|
|
|
const INTL_LOCALE_BY_LOCALE: Record<Locale, string> = {
|
|
en: 'en-US',
|
|
de: 'de-DE',
|
|
fr: 'fr-FR',
|
|
'zh-CN': 'zh-CN',
|
|
'zh-TW': 'zh-TW',
|
|
uk: 'uk-UA',
|
|
es: 'es-ES',
|
|
'pt-BR': 'pt-BR',
|
|
ko: 'ko-KR',
|
|
pl: 'pl-PL',
|
|
ja: 'ja-JP',
|
|
};
|
|
|
|
const getIntlLocale = (locale: Locale): string => INTL_LOCALE_BY_LOCALE[locale] ?? 'en-US';
|
|
|
|
export const getCurrentIntlLocale = (): string => getIntlLocale(useI18nStore.getState().locale);
|