diff --git a/lingui.config.js b/lingui.config.js index 55bbbde3..14841e5d 100644 --- a/lingui.config.js +++ b/lingui.config.js @@ -1,5 +1,7 @@ +import { LOCALES } from './src/locales'; + const config = { - locales: ['en', 'pseudo-LOCALE'], + locales: LOCALES, pseudoLocale: 'pseudo-LOCALE', fallbackLocales: { default: 'en', diff --git a/src/components/lang-selector.jsx b/src/components/lang-selector.jsx index a8964083..bfa8b5cf 100644 --- a/src/components/lang-selector.jsx +++ b/src/components/lang-selector.jsx @@ -1,6 +1,7 @@ import { useLingui } from '@lingui/react'; -import { activateLang, DEFAULT_LANG, LOCALES } from '../utils/lang'; +import { DEFAULT_LANG, LOCALES } from '../locales'; +import { activateLang } from '../utils/lang'; import localeCode2Text from '../utils/localeCode2Text'; export default function LangSelector() { diff --git a/src/locales.js b/src/locales.js new file mode 100644 index 00000000..c951f10f --- /dev/null +++ b/src/locales.js @@ -0,0 +1,7 @@ +export const DEFAULT_LANG = 'en'; + +const locales = [DEFAULT_LANG]; +if (import.meta.env.DEV) { + locales.push('pseudo-LOCALE'); +} +export const LOCALES = locales; diff --git a/src/utils/lang.js b/src/utils/lang.js index 6afc6cd7..a72c2200 100644 --- a/src/utils/lang.js +++ b/src/utils/lang.js @@ -7,17 +7,12 @@ import { } from '@lingui/detect-locale'; import Locale from 'intl-locale-textinfo-polyfill'; +import { DEFAULT_LANG, LOCALES } from '../locales'; import { messages } from '../locales/en.po'; import localeMatch from '../utils/locale-match'; const { PHANPY_DEFAULT_LANG } = import.meta.env; -export const DEFAULT_LANG = 'en'; -export const LOCALES = [DEFAULT_LANG]; -if (import.meta.env.DEV) { - LOCALES.push('pseudo-LOCALE'); -} - i18n.load(DEFAULT_LANG, messages); i18n.on('change', () => { const lang = i18n.locale;