Translate finished messages by template and the world clock, Dropbox and scoped titles at display
This commit is contained in:
1 parent
2b2302a279
commit
f63ecb6697
13 files changed
+139
-28
No files matched your search
@@ -455,11 +455,11 @@ Panel {
|
||||
return text
|
||||
}
|
||||
|
||||
// omarchy-agent-account-add reports progress in English around the agent's name.
|
||||
readonly property var addMessageTemplates: [
|
||||
"Installing the %1 CLI…", "Sign in to %1 again in the browser window that opens.", "Sign in to %1 in the browser window that opens.",
|
||||
"Signed in to %1 again.", "Signed in to %1.", "The %1 sign-in didn't finish.", "Added %1."
|
||||
]
|
||||
// A model-scoped title ("Opus Monthly") keeps the model and translates the window.
|
||||
function windowLabel(title) {
|
||||
var match = String(title || "").match(/^(.*\S)\s+(Monthly|Weekly|Session|Limit)$/)
|
||||
return match ? match[1] + " " + I18n.tr(match[2]) : I18n.tr(String(title || ""))
|
||||
}
|
||||
|
||||
function planLabel(p) {
|
||||
var tier = String(p && p.tierLabel || "")
|
||||
@@ -1173,7 +1173,7 @@ Panel {
|
||||
Text {
|
||||
width: parent.width
|
||||
textFormat: Text.PlainText
|
||||
text: I18n.trMatch(root.addStatus, root.addMessageTemplates)
|
||||
text: I18n.trMessage(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.trMatch(root.addResult, root.addMessageTemplates)
|
||||
text: I18n.trMessage(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.tr(String(section.provider.authHelpText || section.provider.usageStatusText || "")) : ""
|
||||
text: section.provider ? I18n.trMessage(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.tr(String(unavailable.record.authHelpText || "Usage has not been updated yet.")) : ""
|
||||
text: unavailable.record ? I18n.trMessage(String(unavailable.record.authHelpText || "Usage has not been updated yet.")) : ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1904,7 +1904,7 @@ Panel {
|
||||
text: {
|
||||
var lines = []
|
||||
if (compact.window) {
|
||||
lines.push(I18n.tr("%1: %2% used", I18n.tr(compact.window.title), Math.round(compact.window.percent * 100))
|
||||
lines.push(I18n.tr("%1: %2% used", root.windowLabel(compact.window.title), Math.round(compact.window.percent * 100))
|
||||
+ (compact.resetMs > 0 ? " · " + I18n.tr("resets in %1", root.formatDuration(compact.resetMs)) : ""))
|
||||
}
|
||||
if (compact.stale)
|
||||
@@ -1912,8 +1912,8 @@ Panel {
|
||||
? I18n.tr("Last updated %1 ago", root.formatDuration(root.nowMs - compact.fetchedAt))
|
||||
: compact.fetchedAt > 0 ? I18n.tr("Last updated less than a minute ago") : I18n.tr("Last updated time unavailable"))
|
||||
for (var i = 0; i < compact.scoped.length; i++)
|
||||
lines.push(I18n.tr("%1: %2% of its %3 allowance", I18n.tr(compact.scoped[i].title), Math.round(compact.scoped[i].percent * 100),
|
||||
I18n.tr(String(compact.window ? compact.window.title : "")).toLowerCase()))
|
||||
lines.push(I18n.tr("%1: %2% of its %3 allowance", root.windowLabel(compact.scoped[i].title), Math.round(compact.scoped[i].percent * 100),
|
||||
root.windowLabel(compact.window ? compact.window.title : "").toLowerCase()))
|
||||
return lines.join("\n")
|
||||
}
|
||||
}
|
||||
@@ -1923,7 +1923,7 @@ Panel {
|
||||
textFormat: Text.PlainText
|
||||
width: parent.width * 0.3
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: compact.window ? I18n.tr(compact.window.title) : ""
|
||||
text: compact.window ? root.windowLabel(compact.window.title) : ""
|
||||
color: root.foreground
|
||||
font.family: root.fontFamily
|
||||
font.pixelSize: Style.font.bodySmall
|
||||
|
||||
@@ -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.tr(body), app, appIcon)
|
||||
readonly property string styledBody: NotificationLogic.styledBody(I18n.trMessage(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.tr(root.summary)
|
||||
text: I18n.trMessage(root.summary)
|
||||
font.family: "Liberation Sans"
|
||||
color: Color.notifications.text
|
||||
font.pixelSize: Style.font.title
|
||||
|
||||
@@ -90,7 +90,7 @@ Item {
|
||||
font.family: Style.font.family
|
||||
font.bold: true
|
||||
font.pixelSize: Style.font.title
|
||||
text: I18n.tr(root.message)
|
||||
text: I18n.trMessage(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.tr(root.message)
|
||||
text: I18n.trMessage(root.message)
|
||||
font: messageMetrics.font
|
||||
color: Color.popups.text
|
||||
elide: Text.ElideRight
|
||||
|
||||
@@ -37,6 +37,13 @@ Panel {
|
||||
readonly property color dim: Qt.darker(foreground, 1.55)
|
||||
readonly property string fontFamily: bar ? bar.fontFamily : Style.font.family
|
||||
readonly property color iconColor: dropbox.authenticated && dropbox.active ? foreground : dim
|
||||
// Model.fileMeta reads "5m ago · Folder"; the age is translated, the folder name kept.
|
||||
function fileMetaText(file) {
|
||||
var parts = Model.fileMeta(file).split(" · ")
|
||||
parts[0] = I18n.trMatch(parts[0], ["Just now", "Unknown time", "%1mo ago", "%1m ago", "%1h ago", "%1d ago", "%1y ago"])
|
||||
return parts.join(" · ")
|
||||
}
|
||||
|
||||
readonly property string toggleHint: dropbox.active ? I18n.tr("Pause syncing") : I18n.tr("Resume syncing")
|
||||
readonly property color barIconColor: dropbox.authenticated && dropbox.active ? barForeground : Qt.darker(barForeground, 1.55)
|
||||
// Only claim the header cursor when the switch is actually on screen —
|
||||
@@ -284,7 +291,7 @@ Panel {
|
||||
textFormat: Text.PlainText
|
||||
visible: dropbox.actionStatus !== "" || dropbox.lastError !== ""
|
||||
width: parent.width
|
||||
text: dropbox.actionStatus !== "" ? dropbox.actionStatus : dropbox.lastError
|
||||
text: I18n.trMessage(dropbox.actionStatus !== "" ? dropbox.actionStatus : dropbox.lastError)
|
||||
color: dropbox.lastError !== "" && dropbox.actionStatus === "" ? root.urgent : root.dim
|
||||
font.family: root.fontFamily
|
||||
font.pixelSize: Style.font.bodySmall
|
||||
@@ -304,7 +311,7 @@ Panel {
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Style.spacing.labelGap
|
||||
InfoPair { label: I18n.tr("Stored"); value: Model.usageText(dropbox.usedBytes, dropbox.quotaBytes, dropbox.quotaKnown) }
|
||||
InfoPair { label: I18n.tr("Stored"); value: I18n.trMatch(Model.usageText(dropbox.usedBytes, dropbox.quotaBytes, dropbox.quotaKnown), ["%1 of %2"]) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +515,7 @@ Panel {
|
||||
Text {
|
||||
textFormat: Text.PlainText
|
||||
Layout.fillWidth: true
|
||||
text: Model.fileMeta(fileRow.file)
|
||||
text: root.fileMetaText(fileRow.file)
|
||||
color: root.dim
|
||||
font.family: root.fontFamily
|
||||
font.pixelSize: Style.font.caption
|
||||
|
||||
@@ -11,6 +11,16 @@ import "Greetings.js" as Greet
|
||||
Rectangle {
|
||||
id: row
|
||||
|
||||
// Model.formatDate reads "Tue Oct 6"; a Chinese session reads 10月6日 周二.
|
||||
function dateText(date) {
|
||||
var match = String(date).match(/^(\w{3}) (\w{3}) (\d+)$/)
|
||||
if (!I18n.chinese || !match) return date
|
||||
var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].indexOf(match[2]) + 1
|
||||
var weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].indexOf(match[1])
|
||||
if (month < 1 || weekday < 0) return date
|
||||
return month + "月" + match[3] + "日 " + ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][weekday]
|
||||
}
|
||||
|
||||
required property var modelData
|
||||
required property int index
|
||||
// The owning Panel: the row reads its clock, facts and drag state.
|
||||
@@ -222,7 +232,7 @@ Rectangle {
|
||||
Behavior on opacity { NumberAnimation { duration: Style.duration(110) } }
|
||||
|
||||
Caption {
|
||||
text: row.ready ? row.rowData.date : "\u2026"
|
||||
text: row.ready ? row.dateText(row.rowData.date) : "\u2026"
|
||||
color: row.ready && row.rowData.dayLabel !== "" ? row.dim : row.fainter
|
||||
}
|
||||
|
||||
@@ -233,7 +243,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
Caption {
|
||||
text: row.ready ? row.rowData.dayLabel : ""
|
||||
text: row.ready ? I18n.tr(row.rowData.dayLabel) : ""
|
||||
visible: text !== ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ Item {
|
||||
inlineResults: false
|
||||
loading: root.jumpOptions.length === 0
|
||||
buttonText: I18n.tr("Jump to a city")
|
||||
loadingText: "Loading cities\u2026"
|
||||
loadingText: I18n.tr("Loading cities…")
|
||||
offsetLabel: function(zoneId) { return Model.utcOffsetLabel(root.offsets[zoneId]) }
|
||||
foreground: root.foreground
|
||||
dim: root.dim
|
||||
|
||||
@@ -335,7 +335,7 @@ Panel {
|
||||
|
||||
// No full stop: a period hanging off the arc reads as a speck.
|
||||
readonly property string hereLine: I18n.tr("It's %1 here", localTime)
|
||||
+ (homeCity !== "" ? " in " + homeCity : "")
|
||||
+ (homeCity !== "" ? I18n.tr(" in %1", homeCity) : "")
|
||||
+ (scrubLabel !== "" ? " " + scrubLabel : "")
|
||||
|
||||
// A capital's line box has empty space above it; the row's top pad drops by it.
|
||||
|
||||
Reference in new issue
Block a user