Translate the remaining shell text at display and keep translated values out of logic
This commit is contained in:
1 parent
e236713d9f
commit
2b2302a279
17 files changed
+112
-25
No files matched your search
@@ -9,4 +9,8 @@ QtObject {
|
||||
function tr() {
|
||||
return Tr.tr.apply(null, arguments)
|
||||
}
|
||||
|
||||
function trMatch(text, templates) {
|
||||
return Tr.trMatch(text, templates)
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,34 @@ var table = {
|
||||
"Saturday": "星期六",
|
||||
"%1: %2% of its %3 allowance": "%1:占%3额度的 %2%",
|
||||
"Subscriptions": "订阅",
|
||||
"next expires in %1": "下一次%1后过期",
|
||||
"Installing the %1 CLI…": "正在安装 %1 命令行…",
|
||||
"Sign in to %1 again in the browser window that opens.": "在打开的浏览器窗口中重新登录 %1。",
|
||||
"Sign in to %1 in the browser window that opens.": "在打开的浏览器窗口中登录 %1。",
|
||||
"Sign in again as this account in the private window that opens.": "在打开的隐私窗口中以这个账户重新登录。",
|
||||
"Sign in as the account you're adding in the private window that opens.": "在打开的隐私窗口中登录要添加的账户。",
|
||||
"Signed in to %1 again.": "已重新登录 %1。",
|
||||
"Signed in to %1.": "已登录 %1。",
|
||||
"The %1 sign-in didn't finish.": "%1 登录没有完成。",
|
||||
"Added %1.": "已添加 %1。",
|
||||
"Starting…": "正在开始…",
|
||||
"Checking the code…": "正在核对代码…",
|
||||
"Run `claude auth login` to restore authoritative usage.": "运行 `claude auth login` 恢复准确的用量。",
|
||||
"Run `codex login` to authenticate.": "运行 `codex login` 完成认证。",
|
||||
"Set FIREWORKS_API_KEY, run `firectl set-api-key`, or sign in to Fireworks in pi or opencode.": "设置 FIREWORKS_API_KEY,运行 `firectl set-api-key`,或在 pi 或 opencode 中登录 Fireworks。",
|
||||
"Start Grok, or run `grok login`, to sign in.": "启动 Grok 或运行 `grok login` 登录。",
|
||||
"Start Grok to see its limits; signing in again is not needed.": "启动 Grok 查看额度,不需要重新登录。",
|
||||
"Grok's saved sign-in expired. Start Grok to refresh it.": "Grok 保存的登录已过期,启动 Grok 刷新。",
|
||||
"Fireworks unavailable": "Fireworks 不可用",
|
||||
"Fireworks usage scan failed": "Fireworks 用量扫描失败",
|
||||
"Balance unavailable": "余额不可用",
|
||||
"Claude limits unavailable": "Claude 额度不可用",
|
||||
"Codex limits unavailable": "Codex 额度不可用",
|
||||
"Codex unavailable": "Codex 不可用",
|
||||
"Grok limits unavailable": "Grok 额度不可用",
|
||||
"Limits paused": "额度已暂停",
|
||||
"Sign-in expired": "登录已过期",
|
||||
"Waiting for auth": "等待认证",
|
||||
// Network panel
|
||||
"Wiring bits": "接线中",
|
||||
"Handling packets": "处理数据包",
|
||||
@@ -152,6 +180,7 @@ var table = {
|
||||
"Lamp light": "灯光",
|
||||
"Candlelit": "烛光",
|
||||
"Night owl": "夜猫子",
|
||||
"focused": "当前",
|
||||
// Audio panel
|
||||
"Audio": "音频",
|
||||
"OUTPUT": "输出",
|
||||
@@ -225,6 +254,9 @@ var table = {
|
||||
"Battery state": "电池状态",
|
||||
"Discharging": "正在放电",
|
||||
"Holding": "保持中",
|
||||
"Performance": "性能",
|
||||
"Balanced": "均衡",
|
||||
"Power-saver": "省电",
|
||||
// Tailscale panel
|
||||
"Encrypting connections": "加密连接",
|
||||
"Sending secrets": "传递秘密",
|
||||
@@ -449,6 +481,8 @@ var table = {
|
||||
"Sunset": "日落",
|
||||
"It's %1 here": "这里现在是 %1",
|
||||
"Jump to a city": "跳到一个城市",
|
||||
"Add a city": "添加城市",
|
||||
"Loading zones…": "正在加载时区…",
|
||||
// Media
|
||||
"Pause": "暂停",
|
||||
"Play": "播放"
|
||||
|
||||
+16
-3
@@ -5,7 +5,20 @@
|
||||
var chinese = Qt.locale().name.indexOf("zh_CN") === 0
|
||||
|
||||
function tr(text) {
|
||||
var out = chinese && Zh.table[text] !== undefined ? Zh.table[text] : text
|
||||
for (var i = 1; i < arguments.length; i++) out = out.split("%" + i).join(String(arguments[i]))
|
||||
return out
|
||||
var args = arguments
|
||||
var template = chinese && Object.prototype.hasOwnProperty.call(Zh.table, text) ? Zh.table[text] : text
|
||||
// One pass, so an argument that itself contains %2 stays as given.
|
||||
return String(template).replace(/%(\d)/g, function(match, n) {
|
||||
return n > 0 && n < args.length ? String(args[n]) : match
|
||||
})
|
||||
}
|
||||
|
||||
// Text built elsewhere around a name: the first English template that matches is translated with what %1.. captured.
|
||||
function trMatch(text, templates) {
|
||||
for (var i = 0; i < templates.length; i++) {
|
||||
var pattern = "^" + templates[i].replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/%\d/g, "(.+?)") + "$"
|
||||
var match = String(text).match(new RegExp(pattern))
|
||||
if (match) return tr.apply(null, [templates[i]].concat(match.slice(1)))
|
||||
}
|
||||
return tr(text)
|
||||
}
|
||||
Reference in new issue
Block a user