mirror of
https://github.com/open-webui/open-webui
synced 2024-11-08 17:49:57 +00:00
31 lines
870 B
TypeScript
31 lines
870 B
TypeScript
|
import i18next from 'i18next';
|
||
|
import resourcesToBackend from 'i18next-resources-to-backend';
|
||
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||
|
import { createI18nStore, isLoading as isLoadingStore } from './store';
|
||
|
|
||
|
i18next
|
||
|
.use(
|
||
|
resourcesToBackend((language, namespace) => import(`./locales/${language}/${namespace}.json`))
|
||
|
)
|
||
|
.use(LanguageDetector)
|
||
|
.init({
|
||
|
debug: true,
|
||
|
detection: {
|
||
|
order: ['querystring', 'localStorage', 'navigator'],
|
||
|
caches: ['localStorage'],
|
||
|
lookupQuerystring: 'lang',
|
||
|
lookupLocalStorage: 'locale'
|
||
|
},
|
||
|
fallbackLng: 'en',
|
||
|
ns: 'common',
|
||
|
// backend: {
|
||
|
// loadPath: '/locales/{{lng}}/{{ns}}.json'
|
||
|
// }
|
||
|
interpolation: {
|
||
|
escapeValue: false // not needed for svelte as it escapes by default
|
||
|
}
|
||
|
});
|
||
|
const i18n = createI18nStore(i18next);
|
||
|
export default i18n;
|
||
|
export const isLoading = isLoadingStore;
|