blob: 92f0c12fcb3fc5e41b13ca65451f89b91c0c28af (
plain)
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 { BackendModule } from "i18next";
const backend: BackendModule = {
type: "backend",
init() {
/* do nothing */
},
// eslint-disable-next-line @typescript-eslint/no-misused-promises
async read(language, namespace) {
if (namespace === "translation") {
if (language === "en") {
return await import("./translations/en/index.json");
} else if (language === "zh") {
return await import("./translations/zh/index.json");
} else {
throw Error(`Language ${language} is not supported.`);
}
} else if (namespace === "admin") {
if (language === "en") {
return await import("./translations/en/admin.json");
} else if (language === "zh") {
return await import("./translations/zh/admin.json");
} else {
throw Error(`Language ${language} is not supported.`);
}
} else {
throw Error(`Namespace ${namespace} is not supported.`);
}
},
};
export default backend;
|