Merge: Revert removing locales from js bundle

* commit 'ee5456cf8c7cf2d4513d6ee0e6a205cfb987634f':
  Revert remove locales from js bundle
This commit is contained in:
Andrey Meshkov 2020-02-04 13:49:00 +03:00
commit d4069f824a
4 changed files with 113 additions and 37 deletions

23
client/package-lock.json generated vendored
View File

@ -6876,29 +6876,6 @@
"resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-2.2.3.tgz",
"integrity": "sha512-sJZ2n9Vgax0vGer23hJMwyO3FRO7P0dq2DXZPXWE329g3snfJUcw+S24Mp3lqJaxL/0McDu4BD75ds6pzIfhhw=="
},
"i18next-xhr-backend": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-3.2.2.tgz",
"integrity": "sha512-OtRf2Vo3IqAxsttQbpjYnmMML12IMB5e0fc5B7qKJFLScitYaXa1OhMX0n0X/3vrfFlpHL9Ro/H+ps4Ej2j7QQ==",
"requires": {
"@babel/runtime": "^7.5.5"
},
"dependencies": {
"@babel/runtime": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.3.tgz",
"integrity": "sha512-fVHx1rzEmwB130VTkLnxR+HmxcTjGzH12LYQcFFoBwakMd3aOMD4OsRN7tGG/UOYE2ektgFrS8uACAoRk1CY0w==",
"requires": {
"regenerator-runtime": "^0.13.2"
}
},
"regenerator-runtime": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz",
"integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw=="
}
}
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",

1
client/package.json vendored
View File

@ -15,7 +15,6 @@
"date-fns": "^1.29.0",
"i18next": "^12.0.0",
"i18next-browser-languagedetector": "^2.2.3",
"i18next-xhr-backend": "^3.2.2",
"lodash": "^4.17.15",
"nanoid": "^1.2.3",
"prop-types": "^15.7.2",

View File

@ -1,19 +1,130 @@
import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import { reactI18nextModule } from 'react-i18next';
import { initReactI18n } from 'react-i18next/hooks';
import langDetect from 'i18next-browser-languagedetector';
import { LANGUAGES, BASE_LOCALE } from './helpers/twosky';
import vi from './__locales/vi.json';
import en from './__locales/en.json';
import ru from './__locales/ru.json';
import es from './__locales/es.json';
import fr from './__locales/fr.json';
import ja from './__locales/ja.json';
import sv from './__locales/sv.json';
import ptBR from './__locales/pt-br.json';
import zhTW from './__locales/zh-tw.json';
import bg from './__locales/bg.json';
import zhCN from './__locales/zh-cn.json';
import cs from './__locales/cs.json';
import da from './__locales/da.json';
import de from './__locales/de.json';
import id from './__locales/id.json';
import it from './__locales/it.json';
import ko from './__locales/ko.json';
import no from './__locales/no.json';
import nl from './__locales/nl.json';
import pl from './__locales/pl.json';
import ptPT from './__locales/pt-pt.json';
import sk from './__locales/sk.json';
import sl from './__locales/sl.json';
import tr from './__locales/tr.json';
import srCS from './__locales/sr-cs.json';
import hr from './__locales/hr.json';
import fa from './__locales/fa.json';
const resources = {
en: {
translation: en,
},
vi: {
translation: vi,
},
ru: {
translation: ru,
},
es: {
translation: es,
},
fr: {
translation: fr,
},
ja: {
translation: ja,
},
sv: {
translation: sv,
},
'pt-br': {
translation: ptBR,
},
'zh-tw': {
translation: zhTW,
},
bg: {
translation: bg,
},
'zh-cn': {
translation: zhCN,
},
cs: {
translation: cs,
},
da: {
translation: da,
},
de: {
translation: de,
},
id: {
translation: id,
},
it: {
translation: it,
},
ko: {
translation: ko,
},
no: {
translation: no,
},
nl: {
translation: nl,
},
pl: {
translation: pl,
},
'pt-pt': {
translation: ptPT,
},
sk: {
translation: sk,
},
sl: {
translation: sl,
},
tr: {
translation: tr,
},
'sr-cs': {
translation: srCS,
},
hr: {
translation: hr,
},
fa: {
translation: fa,
},
};
const availableLanguages = Object.keys(LANGUAGES);
i18n
.use(langDetect)
.use(XHR)
.use(initReactI18n)
.use(reactI18nextModule)
.init({
resources,
lowerCaseLng: true,
fallbackLng: BASE_LOCALE,
keySeparator: false,
@ -26,9 +137,6 @@ i18n
wait: true,
},
whitelist: availableLanguages,
backend: {
loadPath: '/__locales/{{lng}}.json',
},
}, () => {
if (!availableLanguages.includes(i18n.language)) {
i18n.changeLanguage(BASE_LOCALE);

View File

@ -15,7 +15,6 @@ const HTML_PATH = path.resolve(RESOURCES_PATH, 'public/index.html');
const HTML_INSTALL_PATH = path.resolve(RESOURCES_PATH, 'public/install.html');
const HTML_LOGIN_PATH = path.resolve(RESOURCES_PATH, 'public/login.html');
const FAVICON_PATH = path.resolve(RESOURCES_PATH, 'public/favicon.png');
const LOCALES_PATH = path.resolve(RESOURCES_PATH, 'src/__locales/*.json');
const PUBLIC_PATH = path.resolve(__dirname, '../build/static');
@ -137,13 +136,6 @@ const config = {
new CopyPlugin([
{ from: FAVICON_PATH, to: PUBLIC_PATH },
]),
new CopyPlugin([
{
from: LOCALES_PATH,
to: PUBLIC_PATH,
context: 'src/',
},
]),
],
};