diff --git a/Sources/CodexBar/Date+RelativeDescription.swift b/Sources/CodexBar/Date+RelativeDescription.swift index 7356f96710..cb3c4f59e5 100644 --- a/Sources/CodexBar/Date+RelativeDescription.swift +++ b/Sources/CodexBar/Date+RelativeDescription.swift @@ -4,6 +4,7 @@ enum RelativeTimeFormatters { @MainActor static let full: RelativeDateTimeFormatter = { let formatter = RelativeDateTimeFormatter() + formatter.locale = Locale(identifier: "en_US") formatter.unitsStyle = .full return formatter }() diff --git a/Sources/CodexBar/PreferencesGeneralPane.swift b/Sources/CodexBar/PreferencesGeneralPane.swift index 39a95a55ff..e5bce6ffe1 100644 --- a/Sources/CodexBar/PreferencesGeneralPane.swift +++ b/Sources/CodexBar/PreferencesGeneralPane.swift @@ -152,6 +152,7 @@ struct GeneralPane: View { } if let lastAttempt = self.store.tokenLastAttemptAt(for: provider) { let rel = RelativeDateTimeFormatter() + rel.locale = Locale(identifier: "en_US") rel.unitsStyle = .abbreviated let when = rel.localizedString(for: lastAttempt, relativeTo: Date()) return Text("\(name): last attempt \(when)") diff --git a/Sources/CodexBarCore/Providers/Augment/AugmentStatusProbe.swift b/Sources/CodexBarCore/Providers/Augment/AugmentStatusProbe.swift index 82bf0fdd14..7c8e6bc7c8 100644 --- a/Sources/CodexBarCore/Providers/Augment/AugmentStatusProbe.swift +++ b/Sources/CodexBarCore/Providers/Augment/AugmentStatusProbe.swift @@ -226,6 +226,7 @@ public struct AugmentStatusSnapshot: Sendable { private static func formatResetDate(_ date: Date) -> String { let formatter = RelativeDateTimeFormatter() + formatter.locale = Locale(identifier: "en_US") formatter.unitsStyle = .full return formatter.localizedString(for: date, relativeTo: Date()) } diff --git a/Sources/CodexBarCore/UsageFormatter.swift b/Sources/CodexBarCore/UsageFormatter.swift index 7f7dbae5aa..4b0ba1a8ad 100644 --- a/Sources/CodexBarCore/UsageFormatter.swift +++ b/Sources/CodexBarCore/UsageFormatter.swift @@ -76,6 +76,7 @@ public enum UsageFormatter { if let hours = Calendar.current.dateComponents([.hour], from: date, to: now).hour, hours < 24 { #if os(macOS) let rel = RelativeDateTimeFormatter() + rel.locale = Locale(identifier: "en_US") rel.unitsStyle = .abbreviated return "Updated \(rel.localizedString(for: date, relativeTo: now))" #else diff --git a/Sources/CodexBarWidget/CodexBarWidgetViews.swift b/Sources/CodexBarWidget/CodexBarWidgetViews.swift index 9944d39d80..614103b677 100644 --- a/Sources/CodexBarWidget/CodexBarWidgetViews.swift +++ b/Sources/CodexBarWidget/CodexBarWidgetViews.swift @@ -701,6 +701,7 @@ enum WidgetFormat { static func relativeDate(_ date: Date) -> String { let formatter = RelativeDateTimeFormatter() + formatter.locale = Locale(identifier: "en_US") formatter.unitsStyle = .short return formatter.localizedString(for: date, relativeTo: Date()) } diff --git a/Tests/CodexBarTests/UsageFormatterTests.swift b/Tests/CodexBarTests/UsageFormatterTests.swift index 1358beedf5..15cd689944 100644 --- a/Tests/CodexBarTests/UsageFormatterTests.swift +++ b/Tests/CodexBarTests/UsageFormatterTests.swift @@ -21,9 +21,11 @@ struct UsageFormatterTests { let now = Date() let fiveHoursAgo = now.addingTimeInterval(-5 * 3600) let text = UsageFormatter.updatedString(from: fiveHoursAgo, now: now) - #expect(text.contains("Updated")) - // Check for relative time format (varies by locale: "ago" in English, "전" in Korean, etc.) - #expect(text.contains("5") || text.lowercased().contains("hour") || text.contains("시간")) + #expect(text.hasPrefix("Updated ")) + // Output must stay in English regardless of the host system locale, + // matching the surrounding hardcoded English UI labels. + #expect(text.contains("5")) + #expect(text.lowercased().contains("ago")) } @Test