forked from Lichtblick-Suite/lichtblick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
35 lines (29 loc) · 991 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";
import * as en from "./en";
import * as ja from "./ja";
import * as zh from "./zh";
export const translations = { en, zh, ja };
export type Language = keyof typeof translations;
export const defaultNS = "general";
export async function initI18n(): Promise<void> {
await i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: translations,
detection: {
order: ["localStorage", "navigator"],
caches: ["localStorage"],
},
fallbackLng: "en",
defaultNS,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
});
}