chore: i18n for theme settings

This commit is contained in:
Slinetrac
2025-11-01 10:57:27 +08:00
Unverified
parent 930a4b4d80
commit 21f67f6a45
14 changed files with 325 additions and 23 deletions

View File

@@ -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<DialogRef> }) {
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 (
<Item>
<Item key={key}>
<ListItemText primary={label} />
<Round sx={{ background: theme[key] || dt[key] }} />
<TextField
@@ -81,7 +120,7 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
return (
<BaseDialog
open={open}
title={t("Theme Setting")}
title={t("components.settings.verge.theme.title")}
okBtn={t("Save")}
cancelBtn={t("Cancel")}
contentSx={{ width: 400, maxHeight: 505, overflow: "auto", pb: 0 }}
@@ -90,24 +129,12 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
onOk={onSave}
>
<List sx={{ pt: 0 }}>
{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))}
<Item>
<ListItemText primary={t("Font Family")} />
<ListItemText
primary={t("components.settings.verge.theme.fields.fontFamily")}
/>
<TextField
{...textProps}
value={theme.font_family ?? ""}
@@ -116,7 +143,9 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
/>
</Item>
<Item>
<ListItemText primary={t("CSS Injection")} />
<ListItemText
primary={t("components.settings.verge.theme.fields.cssInjection")}
/>
<Button
startIcon={<EditRounded />}
variant="outlined"
@@ -124,12 +153,12 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
setEditorOpen(true);
}}
>
{t("Edit")} CSS
{t("components.settings.verge.theme.actions.editCss")}
</Button>
{editorOpen && (
<EditorViewer
open={true}
title={`${t("Edit")} CSS`}
title={t("components.settings.verge.theme.dialogs.editCssTitle")}
initialData={Promise.resolve(theme.css_injection ?? "")}
language="css"
onSave={(_prev, curr) => {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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": {