Debian Codegraph @

web/src/app/i18n.js

raw
1 import i18next from "i18next";
2 import Backend from "i18next-http-backend";
3 import LanguageDetector from "i18next-browser-languagedetector";
4 import { initReactI18next } from "react-i18next";
5
6 // Translations using i18next
7 // - Options: https://www.i18next.com/overview/configuration-options
8 // - Browser Language Detector: https://github.com/i18next/i18next-browser-languageDetector
9 // - HTTP Backend (load files via fetch): https://github.com/i18next/i18next-http-backend
10 //
11 // See example project here:
12 // https://github.com/i18next/react-i18next/tree/master/example/react
13
14 const initI18n = () =>
15 i18next
16 .use(Backend)
17 .use(LanguageDetector)
18 .use(initReactI18next)
19 .init({
20 fallbackLng: "en",
21 debug: true,
22 interpolation: {
23 escapeValue: false, // not needed for react as it escapes by default
24 },
25 backend: {
26 loadPath: "/static/langs/{{lng}}.json",
27 },
28 });
29
30 export default initI18n;