Use i18n-http-backend to load translatiosn from json files.

This commit is contained in:
Karel Vendla
2021-04-19 17:07:46 +03:00
parent f9faf31c0d
commit 26b247a638
18 changed files with 79 additions and 41 deletions

View File

@ -1,21 +1,21 @@
import Vue from 'vue';
import i18next from 'i18next';
import VueI18Next from '@panter/vue-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import app from '@/main';
import enJson from '../../public/locales/en';
import estJson from '../../public/locales/est';
Vue.use(VueI18Next);
i18next.use(LanguageDetector);
i18next
.use(LanguageDetector)
.use(Backend);
const initialized = i18next.init({
fallbackLng: 'en',
whitelist: ['en', 'est'],
resources: {
en: enJson,
est: estJson,
whitelist: ['en', 'et'],
backend: {
loadPath: 'locales/{{lng}}/{{ns}}.json',
},
detection: {
order: ['querystring', 'path', 'localStorage', 'navigator'],