From 21f67f6a45c0e4a32e662d2ab7dff543ad3d321b Mon Sep 17 00:00:00 2001 From: Slinetrac Date: Sat, 1 Nov 2025 10:57:27 +0800 Subject: [PATCH] chore: i18n for theme settings --- src/components/setting/mods/theme-viewer.tsx | 75 ++++++++++++++------ src/locales/ar.json | 21 ++++++ src/locales/de.json | 21 ++++++ src/locales/en.json | 21 ++++++ src/locales/es.json | 21 ++++++ src/locales/fa.json | 21 ++++++ src/locales/id.json | 21 ++++++ src/locales/jp.json | 21 ++++++ src/locales/ko.json | 21 ++++++ src/locales/ru.json | 21 ++++++ src/locales/tr.json | 21 ++++++ src/locales/tt.json | 21 ++++++ src/locales/zh.json | 21 ++++++ src/locales/zhtw.json | 21 ++++++ 14 files changed, 325 insertions(+), 23 deletions(-) diff --git a/src/components/setting/mods/theme-viewer.tsx b/src/components/setting/mods/theme-viewer.tsx index 07fc1009..db61da92 100644 --- a/src/components/setting/mods/theme-viewer.tsx +++ b/src/components/setting/mods/theme-viewer.tsx @@ -9,7 +9,7 @@ import { useTheme, } from "@mui/material"; import { useLockFn } from "ahooks"; -import { useImperativeHandle, useState } from "react"; +import { useImperativeHandle, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { BaseDialog, DialogRef } from "@/components/base"; @@ -62,9 +62,48 @@ export function ThemeViewer(props: { ref?: React.Ref }) { type ThemeKey = keyof typeof theme & keyof typeof defaultTheme; - const renderItem = (label: string, key: ThemeKey) => { + const fieldDefinitions: Array<{ labelKey: string; key: ThemeKey }> = useMemo( + () => [ + { + labelKey: "components.settings.verge.theme.fields.primaryColor", + key: "primary_color", + }, + { + labelKey: "components.settings.verge.theme.fields.secondaryColor", + key: "secondary_color", + }, + { + labelKey: "components.settings.verge.theme.fields.primaryText", + key: "primary_text", + }, + { + labelKey: "components.settings.verge.theme.fields.secondaryText", + key: "secondary_text", + }, + { + labelKey: "components.settings.verge.theme.fields.infoColor", + key: "info_color", + }, + { + labelKey: "components.settings.verge.theme.fields.warningColor", + key: "warning_color", + }, + { + labelKey: "components.settings.verge.theme.fields.errorColor", + key: "error_color", + }, + { + labelKey: "components.settings.verge.theme.fields.successColor", + key: "success_color", + }, + ], + [], + ); + + const renderItem = (labelKey: string, key: ThemeKey) => { + const label = t(labelKey); return ( - + }) { return ( }) { onOk={onSave} > - {renderItem(t("Primary Color"), "primary_color")} - - {renderItem(t("Secondary Color"), "secondary_color")} - - {renderItem(t("Primary Text"), "primary_text")} - - {renderItem(t("Secondary Text"), "secondary_text")} - - {renderItem(t("Info Color"), "info_color")} - - {renderItem(t("Warning Color"), "warning_color")} - - {renderItem(t("Error Color"), "error_color")} - - {renderItem(t("Success Color"), "success_color")} + {fieldDefinitions.map((field) => renderItem(field.labelKey, field.key))} - + }) { /> - + {editorOpen && ( { diff --git a/src/locales/ar.json b/src/locales/ar.json index 06d88483..5d586fd1 100644 --- a/src/locales/ar.json +++ b/src/locales/ar.json @@ -1002,6 +1002,27 @@ "latestVersion": "أنت على أحدث إصدار حاليًا", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "إعدادات السمة", + "fields": { + "primaryColor": "اللون الأساسي", + "secondaryColor": "اللون الثانوي", + "primaryText": "النص الأساسي", + "secondaryText": "النص الثانوي", + "infoColor": "لون المعلومات", + "warningColor": "لون التحذير", + "errorColor": "لون الخطأ", + "successColor": "لون النجاح", + "fontFamily": "عائلة الخط", + "cssInjection": "حقن CSS" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/de.json b/src/locales/de.json index ba6caf4c..b3b4b562 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -1002,6 +1002,27 @@ "latestVersion": "Sie verwenden bereits die neueste Version", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Thema-Einstellungen", + "fields": { + "primaryColor": "Hauptfarbe", + "secondaryColor": "Sekundärfarbe", + "primaryText": "Haupttextfarbe", + "secondaryText": "Sekundärtextfarbe", + "infoColor": "Informationsfarbe", + "warningColor": "Warnfarbe", + "errorColor": "Fehlerfarbe", + "successColor": "Erfolgsfarbe", + "fontFamily": "Schriftfamilie", + "cssInjection": "CSS-Einbindung" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/en.json b/src/locales/en.json index 448e1a68..f9a308e6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1002,6 +1002,27 @@ "latestVersion": "Currently on the Latest Version", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Theme Setting", + "fields": { + "primaryColor": "Primary Color", + "secondaryColor": "Secondary Color", + "primaryText": "Primary Text", + "secondaryText": "Secondary Text", + "infoColor": "Info Color", + "warningColor": "Warning Color", + "errorColor": "Error Color", + "successColor": "Success Color", + "fontFamily": "Font Family", + "cssInjection": "CSS Injection" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/es.json b/src/locales/es.json index c7a653e7..c9d71f26 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1002,6 +1002,27 @@ "latestVersion": "Actualmente está en la última versión", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Configuración de tema", + "fields": { + "primaryColor": "Color principal", + "secondaryColor": "Color secundario", + "primaryText": "Color principal del texto", + "secondaryText": "Color secundario del texto", + "infoColor": "Color de información", + "warningColor": "Color de advertencia", + "errorColor": "Color de error", + "successColor": "Color de éxito", + "fontFamily": "Familia tipográfica", + "cssInjection": "Inyección de CSS" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/fa.json b/src/locales/fa.json index ae511441..6ad45b93 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -1002,6 +1002,27 @@ "latestVersion": "در حال حاضر در آخرین نسخه", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "تنظیمات تم", + "fields": { + "primaryColor": "رنگ اصلی", + "secondaryColor": "رنگ ثانویه", + "primaryText": "متن اصلی", + "secondaryText": "متن ثانویه", + "infoColor": "رنگ اطلاعات", + "warningColor": "رنگ هشدار", + "errorColor": "رنگ خطا", + "successColor": "رنگ موفقیت", + "fontFamily": "خانواده فونت", + "cssInjection": "تزریق CSS" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/id.json b/src/locales/id.json index 46d2d035..1a620853 100644 --- a/src/locales/id.json +++ b/src/locales/id.json @@ -1002,6 +1002,27 @@ "latestVersion": "Saat ini pada Versi Terbaru", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Pengaturan Tema", + "fields": { + "primaryColor": "Warna Utama", + "secondaryColor": "Warna Sekunder", + "primaryText": "Teks Utama", + "secondaryText": "Teks Sekunder", + "infoColor": "Warna Info", + "warningColor": "Warna Peringatan", + "errorColor": "Warna Kesalahan", + "successColor": "Warna Keberhasilan", + "fontFamily": "Keluarga Font", + "cssInjection": "Injeksi CSS" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/jp.json b/src/locales/jp.json index 3a961211..00f2844c 100644 --- a/src/locales/jp.json +++ b/src/locales/jp.json @@ -1002,6 +1002,27 @@ "latestVersion": "現在は最新バージョンです。", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "テーマ設定", + "fields": { + "primaryColor": "主要色", + "secondaryColor": "次要色", + "primaryText": "テキスト主要色", + "secondaryText": "テキスト次要色", + "infoColor": "情報色", + "warningColor": "警告色", + "errorColor": "エラー色", + "successColor": "成功色", + "fontFamily": "フォントファミリー", + "cssInjection": "CSSインジェクション" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/ko.json b/src/locales/ko.json index 1a9cd328..5e945953 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -1002,6 +1002,27 @@ "latestVersion": "Currently on the Latest Version", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Theme Setting", + "fields": { + "primaryColor": "기본 색상", + "secondaryColor": "Secondary Color", + "primaryText": "Primary Text", + "secondaryText": "Secondary Text", + "infoColor": "Info Color", + "warningColor": "Warning Color", + "errorColor": "Error Color", + "successColor": "Success Color", + "fontFamily": "Font Family", + "cssInjection": "CSS Injection" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/ru.json b/src/locales/ru.json index 66fcab4c..14030f94 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1002,6 +1002,27 @@ "latestVersion": "Обновление не требуется", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Настройки темы", + "fields": { + "primaryColor": "Основной цвет", + "secondaryColor": "Вторичный цвет", + "primaryText": "Первичный текст", + "secondaryText": "Вторичный текст", + "infoColor": "Информационный цвет", + "warningColor": "Цвет предупреждения", + "errorColor": "Цвет ошибки", + "successColor": "Цвет успеха", + "fontFamily": "Семейство шрифтов", + "cssInjection": "Внедрение CSS" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/tr.json b/src/locales/tr.json index 4d93b5f5..2c43ffc1 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -1002,6 +1002,27 @@ "latestVersion": "Şu Anda En Son Sürümdesiniz", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Tema Ayarı", + "fields": { + "primaryColor": "Ana Renk", + "secondaryColor": "İkincil Renk", + "primaryText": "Ana Metin", + "secondaryText": "İkincil Metin", + "infoColor": "Bilgi Rengi", + "warningColor": "Uyarı Rengi", + "errorColor": "Hata Rengi", + "successColor": "Başarı Rengi", + "fontFamily": "Yazı Tipi Ailesi", + "cssInjection": "CSS Enjeksiyonu" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/tt.json b/src/locales/tt.json index 5c4c0124..027a6b6f 100644 --- a/src/locales/tt.json +++ b/src/locales/tt.json @@ -1002,6 +1002,27 @@ "latestVersion": "Сездә иң соңгы версия урнаштырылган", "versionCopied": "Version copied to clipboard" } + }, + "theme": { + "title": "Тема көйләүләре", + "fields": { + "primaryColor": "Төп төс", + "secondaryColor": "Икенче төс", + "primaryText": "Primary Text", + "secondaryText": "Secondary Text", + "infoColor": "Мәгълүмат төсе", + "warningColor": "Кисәтү төсе", + "errorColor": "Хата төсе", + "successColor": "Уңыш төсе", + "fontFamily": "Шрифтлар гаиләсе", + "cssInjection": "CSS кертү" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/zh.json b/src/locales/zh.json index b31b1c0f..1d0fe05d 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -1002,6 +1002,27 @@ "latestVersion": "当前已是最新版本", "versionCopied": "Verge版本已复制到剪贴板" } + }, + "theme": { + "title": "主题设置", + "fields": { + "primaryColor": "主要颜色", + "secondaryColor": "次要颜色", + "primaryText": "文本主要颜色", + "secondaryText": "文本次要颜色", + "infoColor": "信息颜色", + "warningColor": "警告颜色", + "errorColor": "错误颜色", + "successColor": "成功颜色", + "fontFamily": "字体系列", + "cssInjection": "CSS 注入" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": { diff --git a/src/locales/zhtw.json b/src/locales/zhtw.json index 54158253..3c7491f8 100644 --- a/src/locales/zhtw.json +++ b/src/locales/zhtw.json @@ -1002,6 +1002,27 @@ "latestVersion": "目前已是最新版本", "versionCopied": "Verge版本已複製到剪貼簿" } + }, + "theme": { + "title": "主題設定", + "fields": { + "primaryColor": "主要顏色", + "secondaryColor": "次要顏色", + "primaryText": "文字主要顏色", + "secondaryText": "文字次要顏色", + "infoColor": "資訊顏色", + "warningColor": "警告顏色", + "errorColor": "錯誤顏色", + "successColor": "成功顏色", + "fontFamily": "字型系列", + "cssInjection": "CSS 注入" + }, + "actions": { + "editCss": "Edit CSS" + }, + "dialogs": { + "editCssTitle": "Edit CSS" + } } }, "common": {