import i18n from 'i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; import Backend, { HttpBackendOptions } from 'i18next-http-backend'; import { initReactI18next } from 'react-i18next'; import { trimTrailingSlash } from './utils/common'; i18n // i18next-http-backend // loads translations from your server // https://github.com/i18next/i18next-http-backend .use(Backend) // detect user language // learn more: https://github.com/i18next/i18next-browser-languageDetector .use(LanguageDetector) // pass the i18n instance to react-i18next. .use(initReactI18next) // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ debug: false, fallbackLng: 'en', // Lotus Chat is English-only for now: none of the Lotus-added UI (presence, // calls, soundboard, decorations, seasonal settings, keyboard shortcuts help, // etc.) is routed through useTranslation()/public/locales yet, so letting // LanguageDetector pick a non-English browser locale produced a UI that was // only partially translated (the ~11 upstream strings switched language, // everything Lotus-added stayed English). Restricting supportedLngs keeps // the detector/backend/mechanism intact (see LOTUS_FEATURES.md) so other // languages can come back with a one-line change once Lotus strings are // localized. supportedLngs: ['en'], interpolation: { escapeValue: false, // not needed for react as it escapes by default }, load: 'languageOnly', backend: { loadPath: `${trimTrailingSlash(import.meta.env.BASE_URL)}/public/locales/{{lng}}.json`, }, }); export default i18n;