mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fc448d5b6d
We can't assume that the base URL is `host:port/` - it could be `host:port/some/path/`. Make the path handling dynamic to account for this.
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import i18n from 'i18next';
|
|
import Backend from 'i18next-http-backend';
|
|
import { initReactI18next } from 'react-i18next';
|
|
|
|
// TODO: Disabled for IDE performance issues with our translation JSON
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore
|
|
import translationEN from '../public/locales/en.json';
|
|
|
|
if (import.meta.env.MODE === 'package') {
|
|
i18n.use(initReactI18next).init({
|
|
lng: 'en',
|
|
resources: {
|
|
en: { translation: translationEN },
|
|
},
|
|
debug: false,
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
returnNull: false,
|
|
});
|
|
} else {
|
|
i18n
|
|
.use(Backend)
|
|
// .use(
|
|
// new LanguageDetector(null, {
|
|
// lookupLocalStorage: `${LOCALSTORAGE_PREFIX}lng`,
|
|
// })
|
|
// )
|
|
.use(initReactI18next)
|
|
.init({
|
|
fallbackLng: 'en',
|
|
debug: false,
|
|
backend: {
|
|
loadPath: `${window.location.href.replace(/\/$/, '')}/locales/{{lng}}.json`,
|
|
},
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
returnNull: false,
|
|
});
|
|
}
|
|
|
|
export default i18n;
|