Word parameterized messages at the sender with omarchy-text and translate only exact text in the shell

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 22:29:57 -04:00
1 parent 619979a716
commit 051952600d
38 files changed
+198 -156

No files matched your search

-4
View File
@@ -13,8 +13,4 @@ QtObject {
function trMatch(text, templates) {
return Tr.trMatch(text, templates)
}
function trMessage(text) {
return Tr.trMessage(text)
}
}
+23 -54
View File
@@ -480,7 +480,6 @@ var table = {
"Couldn't add the %1 account": "无法添加 %1 账户",
"Mirroring enabled (%1)": "已开启镜像(%1)",
"New %1 sessions now use %2": "新的 %1 会话现在使用 %2",
"No plugin to %1": "没有插件可以%1",
"No saved width found for %1 on workspace %2": "工作区 %2 没有为 %1 保存的宽度",
"Saved width for %1 on workspace %2": "已为工作区 %2 的 %1 保存宽度",
"Screen recording directory does not exist: %1": "录屏目录不存在:%1",
@@ -528,9 +527,29 @@ var table = {
"The session was left unlocked (%1).": "会话没有锁定(%1)。",
"%1 to %2 (%3)": "%1 转为 %2(%3)",
"Battery %1% · Holding at %2 · %3W / %4Wh": "电池 %1% · 保持在 %2 · %3W / %4Wh",
"Battery %1% · %2 to full · %3W / %4Wh": "电池 %1% · %2 后充满 · %3W / %4Wh",
"Battery %1% · %2 left · %3W / %4Wh": "电池 %1% · 剩余 %2 · %3W / %4Wh",
"%1 · %2 · Week %3": "%1 · %2 · 第 %3 周",
"Battery %1% · %2 to full · %3W / %4Wh": "电池 %1% · %2 后充满 · %3W / %4Wh",
"Battery %1% · %2 left · %3W / %4Wh": "电池 %1% · 剩余 %2 · %3W / %4Wh",
"Week %1": "第 %1 周",
"Installing the %1 CLI didn't finish.": "%1 命令行没有装完。",
"No %1 account named %2.": "没有名为 %2 的 %1 账户。",
"No %1 account named %2": "没有名为 %2 的 %1 账户",
"Couldn't set up a home for the new account.": "无法为新账户准备目录。",
"%1 is not a pending %2 login": "%1 不是待完成的 %2 登录",
"The login didn't finish, so no account was added.": "登录没有完成,没有添加账户。",
"That's %1 (%2). Try again, and sign in as the other account in the private window.": "这是 %1(%2)。请重试,并在隐私窗口中登录另一个账户。",
"already added": "已添加",
"Give the account a name": "给账户起个名字",
"%1 is the login in %2; it can't be removed here.": "%1 是 %2 中的登录,不能在这里移除。",
"A running %1 session uses %2. Quit it first, then remove the account.": "有一个正在运行的 %1 会话使用 %2。先退出它,再移除账户。",
"Switch mode is manual or auto": "切换模式为手动或自动",
"The threshold is a percentage between 50 and 100": "阈值是 50 到 100 之间的百分比",
"%1-min reminder in %2 (%3)": "%1 分钟提醒,还有 %2(%3)",
"%1-min reminder": "%1 分钟提醒",
"Your %1 minutes are up": "%1 分钟到了",
"No plugin to enable": "没有可启用的插件",
"No plugin to disable": "没有可停用的插件",
"No plugin to clone": "没有可克隆的插件",
"No plugin to remove": "没有可移除的插件",
// Clock
"Right-click to toggle format": "右键切换格式",
"Back to today": "回到今天",
@@ -578,53 +597,3 @@ var table = {
"Next": "下一首",
"Previous": "上一首"
}
// Parameterized messages that arrive finished; trMessage matches them, so each needs a table entry above.
var templates = [
"Anthropic's usage endpoint is rate limiting checks right now (retry after %1s). Local Claude Code stats are still shown.",
"Anthropic's usage endpoint returned status %1. Local Claude Code stats are still shown.",
"New %1 sessions now use %2 (%3%). Running sessions stay on %4.",
"Sign in to %1 again in the browser window that opens.",
"%1 is at %2%. Click to switch new sessions to it.",
"Sign in to %1 in the browser window that opens.",
"Screen recording directory does not exist: %1",
"Battery %1% · Holding at %2 · %3W / %4Wh",
"No saved width found for %1 on workspace %2",
"Battery %1% · %2 to full · %3W / %4Wh",
"Battery %1% · %2 left · %3W / %4Wh",
"Click to run %1 pending migrations.",
"The session was left unlocked (%1).",
"Saved width for %1 on workspace %2",
"Staying on %1. %2 resets in %3.",
"%1 is now the default terminal",
"%1 is now the default browser",
"The %1 sign-in didn't finish.",
"%1 is now the default editor",
"All %1 accounts are over %2%",
"Running sessions stay on %1.",
"Couldn't add the %1 account",
"Reminder set for %1 minutes",
"New %1 sessions now use %2",
"Workspace layout set to %1",
"%1 is at %2% of a %3 limit",
"Timezone is now set to %1",
"You'll be reminded at %1",
"Battery is down to %1%",
"Mirroring enabled (%1)",
"Installing the %1 CLI…",
"Signed in to %1 again.",
"%1 · %2 · Week %3",
"Could not send to %1",
"Transcoded to %1 %2",
"Process crashed: %1",
"Signed in to %1.",
"%1 in %2 minutes",
"No plugin to %1",
"Staying on %1.",
"%1 to %2 (%3)",
"%1 installed",
"Received %1",
"Saved to %1",
"Sent to %1",
"Added %1."
]
+1 -6
View File
@@ -13,7 +13,7 @@ function tr(text) {
})
}
// Text built elsewhere around a name: the first English template that matches is translated with what %1.. captured.
// Text a panel's own model builds in known formats: the first matching template 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, "(.+)") + "$"
@@ -22,8 +22,3 @@ function trMatch(text, templates) {
}
return tr(text)
}
// Finished messages from other programs (notifications, collectors) that carry a name or number.
function trMessage(text) {
return trMatch(text, Zh.templates)
}
+4 -4
View File
@@ -1173,7 +1173,7 @@ Panel {
Text {
width: parent.width
textFormat: Text.PlainText
text: I18n.trMessage(root.addStatus)
text: I18n.tr(root.addStatus)
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
@@ -1243,7 +1243,7 @@ Panel {
visible: root.addStage === "done" || root.addStage === "error"
width: parent.width
textFormat: Text.PlainText
text: I18n.trMessage(root.addResult)
text: I18n.tr(root.addResult)
color: root.addStage === "error" ? root.urgent : root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
@@ -1350,7 +1350,7 @@ Panel {
width: parent.width
textFormat: Text.PlainText
// Shown for the status, so a record with no help to offer says the status rather than nothing.
text: section.provider ? I18n.trMessage(String(section.provider.authHelpText || section.provider.usageStatusText || "")) : ""
text: section.provider ? I18n.tr(String(section.provider.authHelpText || section.provider.usageStatusText || "")) : ""
color: root.urgent
font.family: root.fontFamily
font.pixelSize: Style.font.caption
@@ -1879,7 +1879,7 @@ Panel {
PanelToolTip {
visible: unavailableHover.hovered && unavailable.visible
text: unavailable.record ? I18n.trMessage(String(unavailable.record.authHelpText || "Usage has not been updated yet.")) : ""
text: unavailable.record ? I18n.tr(String(unavailable.record.authHelpText || "Usage has not been updated yet.")) : ""
}
}
@@ -44,7 +44,7 @@ BorderSurface {
readonly property bool singleLineToast: sanitizedBody.length === 0
readonly property bool collapseRedundantIcon: singleLineToast && !hasGlyph && summaryStartsWithGlyph
readonly property string sanitizedBody: sanitizeBody(body)
readonly property string styledBody: NotificationLogic.styledBody(I18n.trMessage(body), app, appIcon)
readonly property string styledBody: NotificationLogic.styledBody(I18n.tr(body), app, appIcon)
readonly property color dimColor: Qt.darker(Color.notifications.text, 1.4)
readonly property color bodyColor: Qt.darker(Color.notifications.text, 1.15)
@@ -168,7 +168,7 @@ BorderSurface {
textFormat: Text.PlainText
Layout.fillWidth: true
visible: root.summary.length > 0
text: I18n.trMessage(root.summary)
text: I18n.tr(root.summary)
font.family: "Liberation Sans"
color: Color.notifications.text
font.pixelSize: Style.font.title
+2 -2
View File
@@ -90,7 +90,7 @@ Item {
font.family: Style.font.family
font.bold: true
font.pixelSize: Style.font.title
text: I18n.trMessage(root.message)
text: I18n.tr(root.message)
}
TextMetrics {
@@ -190,7 +190,7 @@ Item {
// a hole in the padding; the slack lands in the gap after the bar.
horizontalAlignment: root.hasProgress ? Text.AlignRight : Text.AlignLeft
anchors.verticalCenter: parent.verticalCenter
text: I18n.trMessage(root.message)
text: I18n.tr(root.message)
font: messageMetrics.font
color: Color.popups.text
elide: Text.ElideRight
+1 -1
View File
@@ -291,7 +291,7 @@ Panel {
textFormat: Text.PlainText
visible: dropbox.actionStatus !== "" || dropbox.lastError !== ""
width: parent.width
text: I18n.trMessage(dropbox.actionStatus !== "" ? dropbox.actionStatus : dropbox.lastError)
text: I18n.tr(dropbox.actionStatus !== "" ? dropbox.actionStatus : dropbox.lastError)
color: dropbox.lastError !== "" && dropbox.actionStatus === "" ? root.urgent : root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall