mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-21 16:55:25 +03:00
Sync the list of locales between config & app code
This commit is contained in:
parent
fcb85d1172
commit
f359d36e9b
4 changed files with 13 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
import { LOCALES } from './src/locales';
|
||||
|
||||
const config = {
|
||||
locales: ['en', 'pseudo-LOCALE'],
|
||||
locales: LOCALES,
|
||||
pseudoLocale: 'pseudo-LOCALE',
|
||||
fallbackLocales: {
|
||||
default: 'en',
|
||||
|
|
|
@ -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() {
|
||||
|
|
7
src/locales.js
Normal file
7
src/locales.js
Normal file
|
@ -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;
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue