implement lightweight i18n support for electron main process

This commit is contained in:
i1Zeus
2026-05-03 20:05:06 +03:00
parent b5d37c4270
commit bb30e20df7
+6 -2
View File
@@ -1,6 +1,8 @@
// Lightweight i18n for the Electron main process.
// Imports the same JSON translation files used by the renderer.
import commonAr from "../src/i18n/locales/ar/common.json";
import dialogsAr from "../src/i18n/locales/ar/dialogs.json";
import commonEn from "../src/i18n/locales/en/common.json";
import dialogsEn from "../src/i18n/locales/en/dialogs.json";
import commonEs from "../src/i18n/locales/es/common.json";
@@ -18,7 +20,7 @@ import dialogsZh from "../src/i18n/locales/zh-CN/dialogs.json";
import commonZhTw from "../src/i18n/locales/zh-TW/common.json";
import dialogsZhTw from "../src/i18n/locales/zh-TW/dialogs.json";
type Locale = "en" | "zh-CN" | "zh-TW" | "es" | "fr" | "ja-JP" | "ko-KR" | "tr";
type Locale = "en" | "zh-CN" | "zh-TW" | "es" | "fr" | "ja-JP" | "ko-KR" | "tr" | "ar";
type Namespace = "common" | "dialogs";
type MessageMap = Record<string, unknown>;
@@ -31,6 +33,7 @@ const messages: Record<Locale, Record<Namespace, MessageMap>> = {
"ja-JP": { common: commonJa, dialogs: dialogsJa },
"ko-KR": { common: commonKo, dialogs: dialogsKo },
tr: { common: commonTr, dialogs: dialogsTr },
ar: { common: commonAr, dialogs: dialogsAr },
};
let currentLocale: Locale = "en";
@@ -44,7 +47,8 @@ export function setMainLocale(locale: string) {
locale === "fr" ||
locale === "ja-JP" ||
locale === "ko-KR" ||
locale === "tr"
locale === "tr" ||
locale === "ar"
) {
currentLocale = locale;
}