aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/i18n/backend.ts
diff options
context:
space:
mode:
Diffstat (limited to 'FrontEnd/src/i18n/backend.ts')
-rw-r--r--FrontEnd/src/i18n/backend.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/FrontEnd/src/i18n/backend.ts b/FrontEnd/src/i18n/backend.ts
new file mode 100644
index 00000000..92f0c12f
--- /dev/null
+++ b/FrontEnd/src/i18n/backend.ts
@@ -0,0 +1,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;
+