diff options
Diffstat (limited to 'frontend/src/index.tsx')
| -rw-r--r-- | frontend/src/index.tsx | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index eafa9616..27217f96 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -1,4 +1,8 @@ import { Navigation, Router, sleep } from 'decky-frontend-lib'; +import i18n from 'i18next'; +import LanguageDetector from 'i18next-browser-languagedetector'; +import Backend from 'i18next-http-backend'; +import { initReactI18next } from 'react-i18next'; import PluginLoader from './plugin-loader'; import { DeckyUpdater } from './updater'; @@ -36,9 +40,35 @@ declare global { (async () => { window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text()); + i18n + .use(Backend) + .use(LanguageDetector) + .use(initReactI18next) + .init({ + load: 'currentOnly', + detection: { + order: ['querystring', 'navigator'], + lookupQuerystring: 'lng', + }, + //debug: true, + fallbackLng: 'en-US', + interpolation: { + escapeValue: true, + }, + returnEmptyString: false, + backend: { + loadPath: 'http://127.0.0.1:1337/locales/{{lng}}.json', + customHeaders: { + Authentication: window.deckyAuthToken, + }, + requestOptions: { + credentials: 'include', + }, + }, + }); + window.DeckyPluginLoader?.dismountAll(); window.DeckyPluginLoader?.deinit(); - window.DeckyPluginLoader = new PluginLoader(); window.DeckyPluginLoader.init(); window.importDeckyPlugin = function (name: string, version: string) { @@ -62,3 +92,5 @@ declare global { setTimeout(() => window.syncDeckyPlugins(), 5000); })(); + +export default i18n; |
