From ea12f39b7a68c95653154e21db6a9f3ab8ec6f11 Mon Sep 17 00:00:00 2001 From: lonewolfyx Date: Thu, 16 Jul 2026 09:38:48 +0800 Subject: [PATCH] feat: localize the weekly quota menu bar prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the hardcoded "1w" weekly-quota prefix shown in the menu bar with a localized `shortWeek` string, so the prefix follows the app language instead of always rendering the English abbreviation. - I18n: add `shortWeek` key — en "Weekly", zh-Hans "周剩" - CodexRateLimitService: return `I18n.current.shortWeek` for the 10080-min (1w) rate-limit window instead of the literal "1w" - MenuBarQuotaView: use `I18n.current.shortWeek` for both the initial label and the empty-snapshot fallback, dropping the remaining "1w" literals Co-Authored-By: Claude --- Sources/AgentBar/Localization/I18n.swift | 3 +++ Sources/AgentBar/Services/CodexRateLimitService.swift | 2 +- Sources/AgentBar/UI/MenuBarQuotaView.swift | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/AgentBar/Localization/I18n.swift b/Sources/AgentBar/Localization/I18n.swift index 2088fdf..d620e4f 100644 --- a/Sources/AgentBar/Localization/I18n.swift +++ b/Sources/AgentBar/Localization/I18n.swift @@ -18,6 +18,7 @@ enum I18n { let aboutUs: String let quit: String let recentWeek: String + let shortWeek: String let resetTimeUnavailable: String let resetSoon: String let refreshAtSuffix: String @@ -242,6 +243,7 @@ enum I18n { aboutUs: "About us", quit: "Quit", recentWeek: "Past 1 week", + shortWeek: "Weekly", resetTimeUnavailable: "Reset time unavailable", resetSoon: "Reset soon", refreshAtSuffix: " refresh", @@ -287,6 +289,7 @@ enum I18n { aboutUs: "关于我们", quit: "退出", recentWeek: "近 1 周", + shortWeek: "周剩", resetTimeUnavailable: "刷新时间不可用", resetSoon: "即将刷新", refreshAtSuffix: "刷新", diff --git a/Sources/AgentBar/Services/CodexRateLimitService.swift b/Sources/AgentBar/Services/CodexRateLimitService.swift index 5d3dc5f..50ff0f1 100644 --- a/Sources/AgentBar/Services/CodexRateLimitService.swift +++ b/Sources/AgentBar/Services/CodexRateLimitService.swift @@ -214,7 +214,7 @@ struct CodexRateLimitService { switch durationMins { case 10080: - return "1w" + return I18n.current.shortWeek case ..<1440: return "\(max(1, durationMins / 60))h" default: diff --git a/Sources/AgentBar/UI/MenuBarQuotaView.swift b/Sources/AgentBar/UI/MenuBarQuotaView.swift index c750c89..d529d7a 100644 --- a/Sources/AgentBar/UI/MenuBarQuotaView.swift +++ b/Sources/AgentBar/UI/MenuBarQuotaView.swift @@ -2,7 +2,7 @@ import AppKit final class MenuBarQuotaView: NSControl { private let iconView = NSImageView() - private let weekPrefixLabel = NSTextField(labelWithString: "1w") + private let weekPrefixLabel = NSTextField(labelWithString: I18n.current.shortWeek) private let weekPercentLabel = NSTextField(labelWithString: "--") override init(frame frameRect: NSRect) { @@ -19,7 +19,7 @@ final class MenuBarQuotaView: NSControl { toolTip = statusMessage guard let snapshot else { - weekPrefixLabel.stringValue = "1w" + weekPrefixLabel.stringValue = I18n.current.shortWeek weekPercentLabel.stringValue = "--" weekPercentLabel.textColor = .secondaryLabelColor return