Created the i18n.js
This commit is contained in:
parent
80ab127bf7
commit
dbb4e95417
26
webui/src/i18n.js
Normal file
26
webui/src/i18n.js
Normal file
@ -0,0 +1,26 @@
|
||||
import i18n from "i18next";
|
||||
import {initReactI18next} from "react-i18next";
|
||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||
import HttpApi from 'i18next-http-backend';
|
||||
|
||||
if (localStorage.getItem('language') === null)
|
||||
localStorage.setItem('language', navigator.language.split('-')[0]);
|
||||
|
||||
export const languages = {
|
||||
de: "Deutsch",
|
||||
en: "English"
|
||||
}
|
||||
|
||||
i18n.use(initReactI18next).use(LanguageDetector).use(HttpApi).init({
|
||||
supportedLngs: Object.keys(languages),
|
||||
fallbackLng: 'en',
|
||||
backend: {
|
||||
loadPath: '/assets/locales/{{lng}}.json'
|
||||
},
|
||||
detection: {
|
||||
order: ['localStorage'],
|
||||
lookupLocalStorage: 'language'
|
||||
}
|
||||
});
|
||||
|
||||
export default i18n;
|
Reference in New Issue
Block a user