0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/plugins/ui-theme/i18n/config.ts
Juan Picado e9e4552658 feat: ui theme on 5.x (#2033)
* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* chore: fix lint

* chore: add missing folder

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* chore: update scripts

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin

* refactor: relocate theme-ui as plugin
2021-04-09 17:54:29 +02:00

94 lines
2.2 KiB
TypeScript

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import translationCS from './translations/cs-CZ.json';
import translationDE from './translations/de-DE.json';
import translationEN from './translations/en-US.json';
import translationES from './translations/es-ES.json';
import translationFR from './translations/fr-FR.json';
import translationJP from './translations/ja-JP.json';
import translationKM from './translations/km-KH.json';
import translationPT from './translations/pt-BR.json';
import translationRU from './translations/ru-RU.json';
import translationTR from './translations/tr-TR.json';
import translationUA from './translations/uk-UA.json';
import translationCN from './translations/zh-CN.json';
import translatiobTW from './translations/zh-TW.json';
const languages = {
'en-US': {
translation: translationEN,
},
'cs-CZ': {
translation: translationCS,
},
'pt-BR': {
translation: translationPT,
},
'es-ES': {
translation: translationES,
},
'de-DE': {
translation: translationDE,
},
'fr-FR': {
translation: translationFR,
},
'zh-CN': {
translation: translationCN,
},
'ja-JP': {
translation: translationJP,
},
'ru-RU': {
translation: translationRU,
},
'tr-TR': {
translation: translationTR,
},
'uk-UA': {
translation: translationUA,
},
'km-KH': {
translation: translationKM,
},
'zh-TW': {
translation: translatiobTW,
},
};
type Language = keyof typeof languages;
i18n
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
// in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US'
lng: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.language || 'en-US',
fallbackLng: 'en-US',
whitelist: [
'en-US',
'cs-CZ',
'pt-BR',
'es-ES',
'de-DE',
'fr-FR',
'zh-CN',
'ja-JP',
'ru-RU',
'tr-TR',
'uk-UA',
'km-KH',
'zh-TW',
],
load: 'currentOnly',
resources: languages,
debug: false,
interpolation: {
escapeValue: false, // react already safes from xss
},
});
export default i18n;
export { Language };