-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi18n.ts
33 lines (30 loc) · 918 Bytes
/
i18n.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
import i18next from "https://deno.land/x/i18next/index.js";
import Backend from "https://deno.land/x/i18next_fs_backend/index.js";
// import enTranslation from "./locales/en/translation.json" assert {
// type: "json",
// };
// import deTranslation from "./locales/de/translation.json" assert {
// type: "json",
// };
const systemLocale = Intl.DateTimeFormat().resolvedOptions().locale;
i18next
.use(Backend)
.init({
// debug: true,
initAsync: false, // setting initAsync to false, will load the resources synchronously
fallbackLng: "en",
preload: ['en', 'de'],
backend: {
loadPath: "locales/{{lng}}/{{ns}}.json",
},
// resources: {
// en: {
// translation: enTranslation,
// },
// de: {
// translation: deTranslation,
// },
// },
});
export default (lng: string | undefined | null) =>
i18next.getFixedT(lng || systemLocale);