Skip to content

feat: localize condition text and forecast weekdays (--language) - #2

Open
KSxx wants to merge 2 commits into
mryll:masterfrom
KSxx:i18n-condition-text
Open

feat: localize condition text and forecast weekdays (--language)#2
KSxx wants to merge 2 commits into
mryll:masterfrom
KSxx:i18n-condition-text

Conversation

@KSxx

@KSxx KSxx commented Sep 3, 2026

Copy link
Copy Markdown

Closes #1.

What

  • --language <en|de>, falling back to LC_MESSAGESLANG → English, per the design we settled on in Localize weather condition text (and forecast date formatting) #1.
  • Translation lives in a new src/i18n.rs: a plain match, no i18n crate, matching the rest of the codebase's philosophy.
  • Applied once, in icons::get_icon/get_icon_plain, so the Waybar tooltip and the structured JSON (and therefore the Omarchy panel) stay in sync — the same way icon_set already threads through both.
  • Also localizes the daily forecast's weekday abbreviation (waybar.rs::short_day_name), since chrono's %a can't do that without the unstable-locales feature. Small fixed table in i18n.rs instead — same reasoning as the condition strings, no new dependency. I checked Panel.qml's own weekday label (Qt.formatDate "ddd"): it already follows the system locale on its own, so no QML change was needed there.
  • Per your note on Localize weather condition text (and forecast date formatting) #1: language is not in manifest.json — the Omarchy panel reads it the same path units already takes, setting("language", "") threaded through buildCmd(), set (if at all) directly in shell.json.

Coverage

  • i18n::every_condition_string_is_translated iterates icons::all_descriptions() (the same table icons.rs owns), so a new WMO code added later without a German entry fails the suite instead of shipping silently untranslated.
  • structured::structured_output_is_localized and waybar::german_language_localizes_the_tooltip check both output surfaces end to end.
  • Language::resolve has its own coverage: flag-wins, LC_MESSAGES over LANG, an explicit en* short-circuiting a later de* variable, unknown/missing locale defaulting to English.
  • Manually verified against the real API with --language de, with LANG=de_DE.UTF-8/LC_MESSAGES (no flag), on both --output json and the Waybar tooltip — condition text and weekday abbreviations (Do 03, Fr 04, Sa 05) all correct.
  • cargo test, cargo clippy --all-targets, cargo fmt, qmllint omarchy/Panel.qml all clean. The two too_many_arguments clippy warnings on build_tooltip/build_output predate this PR (verified against master); this just adds one more argument to each.

🤖 Generated with Claude Code

Adds --language <en|de>, falling back to LC_MESSAGES then LANG, then
English, per the design discussed in mryll#1. Translation lives in a new
i18n.rs (plain match, no i18n crate) and is applied once, in
icons::get_icon/get_icon_plain, so the Waybar tooltip and the
structured JSON (and therefore the Omarchy panel) stay in sync the
same way icon_set already does.

Also localizes the daily forecast's weekday abbreviation
(waybar.rs::short_day_name), which chrono's %a cannot do without the
unstable-locales feature — a small fixed table in i18n.rs instead,
same "no extra machinery" spirit as the condition strings. The
Omarchy panel's own weekday label (Qt.formatDate "ddd") already
follows the system locale, so no QML change was needed there.

Per the thread on mryll#1: language is not added to manifest.json (that
stays config-agnostic); the Omarchy panel reads it the same way it
reads units, via setting("language", "") threaded through buildCmd(),
set (if at all) directly in shell.json.

i18n::every_condition_string_is_translated iterates
icons::all_descriptions() so a WMO code added without a German entry
fails the test suite instead of shipping untranslated.

Closes mryll#1

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016CrAMuqtTnQDwanMruP69d
Same pattern as icon_set/palette: --language resolves once and is
applied in icons::get_icon/get_icon_plain so both output surfaces
stay in sync, language stays out of manifest.json, and the
translation-coverage test is called out so a future WMO code doesn't
ship untranslated by accident.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lqfp2RQAo2tx3cvtw7DzKq
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.

Localize weather condition text (and forecast date formatting)

1 participant