aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/i18n.ts
diff options
context:
space:
mode:
Diffstat (limited to 'FrontEnd/src/i18n.ts')
-rw-r--r--FrontEnd/src/i18n.ts47
1 files changed, 22 insertions, 25 deletions
diff --git a/FrontEnd/src/i18n.ts b/FrontEnd/src/i18n.ts
index 9bf8721f..59b6f64a 100644
--- a/FrontEnd/src/i18n.ts
+++ b/FrontEnd/src/i18n.ts
@@ -4,34 +4,31 @@ import { initReactI18next } from "react-i18next";
const backend: BackendModule = {
type: "backend",
- read(language, namespace, callback) {
- (async () => {
- if (namespace === "translation") {
- if (language === "en") {
- return await import("./locales/en/translation.json");
- } else if (language === "zh") {
- return await import("./locales/zh/translation.json");
- } else {
- throw Error(`Language ${language} is not supported.`);
- }
- } else if (namespace === "admin") {
- if (language === "en") {
- return await import("./locales/en/admin.json");
- } else if (language === "zh") {
- return await import("./locales/zh/admin.json");
- } else {
- throw Error(`Language ${language} is not supported.`);
- }
+ 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("./locales/en/translation.json");
+ } else if (language === "zh") {
+ return await import("./locales/zh/translation.json");
+ } else {
+ throw Error(`Language ${language} is not supported.`);
+ }
+ } else if (namespace === "admin") {
+ if (language === "en") {
+ return await import("./locales/en/admin.json");
+ } else if (language === "zh") {
+ return await import("./locales/zh/admin.json");
} else {
- throw Error(`Namespace ${namespace} is not supported.`);
+ throw Error(`Language ${language} is not supported.`);
}
- })().then(
- (resources) => callback(null, resources.default),
- (error: Error) => callback(error, null),
- );
+ } else {
+ throw Error(`Namespace ${namespace} is not supported.`);
+ }
},
- init() {}, // eslint-disable-line @typescript-eslint/no-empty-function
- create() {}, // eslint-disable-line @typescript-eslint/no-empty-function
};
export const i18nPromise = i18n