feat: add theme translation keys for light, dark, and system modes in multiple locales
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ scripts/_env.sh
|
|||||||
.vscode
|
.vscode
|
||||||
.tool-versions
|
.tool-versions
|
||||||
.idea
|
.idea
|
||||||
|
.old
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ function getAllSourceContent() {
|
|||||||
return files.map(f => fs.readFileSync(f, 'utf8')).join('\n');
|
return files.map(f => fs.readFileSync(f, 'utf8')).join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 白名单 key,不检查这些 key 是否被使用
|
||||||
|
const WHITELIST_KEYS = [
|
||||||
|
'theme.light',
|
||||||
|
'theme.dark',
|
||||||
|
'theme.system'
|
||||||
|
];
|
||||||
|
|
||||||
// 主流程
|
// 主流程
|
||||||
function processI18nFile(i18nPath, lang, allSource) {
|
function processI18nFile(i18nPath, lang, allSource) {
|
||||||
const i18n = JSON.parse(fs.readFileSync(i18nPath, 'utf8'));
|
const i18n = JSON.parse(fs.readFileSync(i18nPath, 'utf8'));
|
||||||
@@ -43,12 +50,16 @@ function processI18nFile(i18nPath, lang, allSource) {
|
|||||||
let checked = 0;
|
let checked = 0;
|
||||||
const total = keys.length;
|
const total = keys.length;
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
// 只查找一次
|
if (WHITELIST_KEYS.includes(key)) {
|
||||||
const regex = new RegExp(`["'\`]${key}["'\`]`);
|
|
||||||
if (regex.test(allSource)) {
|
|
||||||
used[key] = i18n[key];
|
used[key] = i18n[key];
|
||||||
} else {
|
} else {
|
||||||
unused.push(key);
|
// 只查找一次
|
||||||
|
const regex = new RegExp(`["'\`]${key}["'\`]`);
|
||||||
|
if (regex.test(allSource)) {
|
||||||
|
used[key] = i18n[key];
|
||||||
|
} else {
|
||||||
|
unused.push(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
checked++;
|
checked++;
|
||||||
if (checked % 20 === 0 || checked === total) {
|
if (checked % 20 === 0 || checked === total) {
|
||||||
|
|||||||
@@ -280,6 +280,9 @@
|
|||||||
"Verge Advanced Setting": "Verge Advanced Setting",
|
"Verge Advanced Setting": "Verge Advanced Setting",
|
||||||
"Language": "Language",
|
"Language": "Language",
|
||||||
"Theme Mode": "Theme Mode",
|
"Theme Mode": "Theme Mode",
|
||||||
|
"theme.light": "Light",
|
||||||
|
"theme.dark": "Dark",
|
||||||
|
"theme.system": "System",
|
||||||
"Tray Click Event": "Tray Click Event",
|
"Tray Click Event": "Tray Click Event",
|
||||||
"Show Main Window": "Show Main Window",
|
"Show Main Window": "Show Main Window",
|
||||||
"Show Tray Menu": "Show Tray Menu",
|
"Show Tray Menu": "Show Tray Menu",
|
||||||
@@ -564,4 +567,4 @@
|
|||||||
"Failed to save settings": "Failed to save settings",
|
"Failed to save settings": "Failed to save settings",
|
||||||
"TCP Concurrency": "TCP Concurrency",
|
"TCP Concurrency": "TCP Concurrency",
|
||||||
"TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses.": "TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses."
|
"TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses.": "TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses."
|
||||||
}
|
}
|
||||||
@@ -280,6 +280,9 @@
|
|||||||
"Verge Advanced Setting": "Verge詳細設定",
|
"Verge Advanced Setting": "Verge詳細設定",
|
||||||
"Language": "言語設定",
|
"Language": "言語設定",
|
||||||
"Theme Mode": "テーマモード",
|
"Theme Mode": "テーマモード",
|
||||||
|
"theme.light": "ライト",
|
||||||
|
"theme.dark": "ダーク",
|
||||||
|
"theme.system": "システム",
|
||||||
"Tray Click Event": "トレイアイコンクリックイベント",
|
"Tray Click Event": "トレイアイコンクリックイベント",
|
||||||
"Show Main Window": "メインウィンドウを表示",
|
"Show Main Window": "メインウィンドウを表示",
|
||||||
"Show Tray Menu": "トレイメニューを表示",
|
"Show Tray Menu": "トレイメニューを表示",
|
||||||
|
|||||||
@@ -280,6 +280,9 @@
|
|||||||
"Verge Advanced Setting": "Verge 高级设置",
|
"Verge Advanced Setting": "Verge 高级设置",
|
||||||
"Language": "语言设置",
|
"Language": "语言设置",
|
||||||
"Theme Mode": "主题模式",
|
"Theme Mode": "主题模式",
|
||||||
|
"theme.light": "浅色",
|
||||||
|
"theme.dark": "深色",
|
||||||
|
"theme.system": "系统",
|
||||||
"Tray Click Event": "托盘点击事件",
|
"Tray Click Event": "托盘点击事件",
|
||||||
"Show Main Window": "显示主窗口",
|
"Show Main Window": "显示主窗口",
|
||||||
"Show Tray Menu": "显示托盘菜单",
|
"Show Tray Menu": "显示托盘菜单",
|
||||||
@@ -564,4 +567,4 @@
|
|||||||
"Failed to save settings": "端口设置失败",
|
"Failed to save settings": "端口设置失败",
|
||||||
"TCP Concurrency": "TCP并发",
|
"TCP Concurrency": "TCP并发",
|
||||||
"TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses.": "TCP 并发性当访问网页时,DNS 解析通常会产生多个 IP 地址。"
|
"TCP ConcurrencyWhen accessing a web page, DNS resolution generally results in multiple IP addresses.": "TCP 并发性当访问网页时,DNS 解析通常会产生多个 IP 地址。"
|
||||||
}
|
}
|
||||||
@@ -280,6 +280,9 @@
|
|||||||
"Verge Advanced Setting": "Verge 高級設置",
|
"Verge Advanced Setting": "Verge 高級設置",
|
||||||
"Language": "語言設置",
|
"Language": "語言設置",
|
||||||
"Theme Mode": "主題模式",
|
"Theme Mode": "主題模式",
|
||||||
|
"theme.light": "淺色",
|
||||||
|
"theme.dark": "深色",
|
||||||
|
"theme.system": "系統",
|
||||||
"Tray Click Event": "托盤點擊事件",
|
"Tray Click Event": "托盤點擊事件",
|
||||||
"Show Main Window": "顯示主窗口",
|
"Show Main Window": "顯示主窗口",
|
||||||
"Show Tray Menu": "顯示托盤菜單",
|
"Show Tray Menu": "顯示托盤菜單",
|
||||||
|
|||||||
Reference in New Issue
Block a user