Skip to content

fix: pin RelativeDateTimeFormatter to en_US to stop mixed-locale labels#868

Merged
steipete merged 1 commit intosteipete:mainfrom
Karl-Dai:claude/dazzling-hodgkin-702bf2
May 8, 2026
Merged

fix: pin RelativeDateTimeFormatter to en_US to stop mixed-locale labels#868
steipete merged 1 commit intosteipete:mainfrom
Karl-Dai:claude/dazzling-hodgkin-702bf2

Conversation

@Karl-Dai
Copy link
Copy Markdown
Contributor

@Karl-Dai Karl-Dai commented May 8, 2026

Summary

  • Closes Menu card 'Updated' timestamp mixes English label with localized relative time on non-English systems #866. On non-English macOS systems (Chinese, Korean, etc.) the menu card timestamp rendered as a mix of hardcoded English and the system-localized relative time, e.g. Updated 1分钟前, then flipped to Updated just now once the snapshot got within 60 s — the same field visibly switching languages while the menu was open.
  • Root cause: five RelativeDateTimeFormatter instances never set formatter.locale, while every surrounding string (Updated, just now, Xm ago, last attempt …, Resets …) is hardcoded English. Other formatters in the same files already pin Locale(identifier: "en_US"/"en_US_POSIX") (see UsageFormatter.usdString); these sites just missed the pattern.

Changes

  • Sources/CodexBarCore/UsageFormatter.swiftupdatedString.
  • Sources/CodexBar/Date+RelativeDescription.swiftRelativeTimeFormatters.full.
  • Sources/CodexBar/PreferencesGeneralPane.swift — token last attempt … line.
  • Sources/CodexBarCore/Providers/Augment/AugmentStatusProbe.swift — Augment reset-date formatter.
  • Sources/CodexBarWidget/CodexBarWidgetViews.swift — widget relative date.
  • Tests/CodexBarTests/UsageFormatterTests.swift — tightened the relative updated recent test, which previously accepted Korean output (시간) as a workaround for this bug, to assert English output.

Verification

Reproduced and confirmed with a standalone Swift snippet that mirrors updatedString under Locale.current = zh_CN:

output
before fix Updated 5小时前
after fix Updated 5h ago

I could not run swift test locally — the SwiftPM CLI hits an unrelated external macro implementation type 'PreviewsMacros.SwiftUIView' could not be found error inside the third-party KeyboardShortcuts package's #Preview { … } previews, and xcodebuild requires Xcode (this machine only has CommandLineTools). The change is mechanical, follows the existing locale-pinning pattern in UsageFormatter.swift, and the updated test asserts the corrected behavior; please rely on CI to confirm.

Test plan

  • CI swift test green (esp. UsageFormatterTests/relative updated recent).
  • On a zh_CN / ja_JP / ko_KR system, open the menu bar popover and confirm the Updated … line stays fully English (Updated just now, Updated 5h ago, Updated <time>).
  • Preferences → Provider tokens row: confirm last attempt … text is English.
  • Widget: confirm relative-date text is English.

Five RelativeDateTimeFormatter sites lacked an explicit locale, so on
non-English systems they emitted localized output (e.g. "1分钟前") next
to hardcoded English labels like "Updated", producing strings such as
"Updated 1分钟前". The same field flipped to "Updated just now" inside
the 60-second window, visibly switching languages while the menu was
open.

Pin every RelativeDateTimeFormatter to Locale(identifier: "en_US"),
matching the en_US / en_US_POSIX pattern already used by every other
formatter in UsageFormatter.swift.

Tighten the existing relative-updated test, which previously accepted
Korean output as a workaround for this bug, to assert English output.

Closes steipete#866
@steipete steipete merged commit dcb4706 into steipete:main May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu card 'Updated' timestamp mixes English label with localized relative time on non-English systems

2 participants