Repository navigation
feat(i18n): share typed English strings across terminal and GUI - #865
Conversation
Move interface copy into one typed, serializable English catalog shared by the terminal and browser. Add tolerant language selection, boot-time locale resolution, live refresh, raw-preserving setting choices and cell-safe layouts. Chinese language choices use English fallback tables in this PR; translated areas follow in stacked PRs. Keep CLI output and diagnostics in English.
|
Important Review skippedToo many files! This PR contains 248 files, which is 98 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configuration
⛔ Files ignored due to path filters: 25
📒 Files selected for processing: 248
You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
LargeModGames
left a comment
There was a problem hiding this comment.
The help fixture pins <Ctrl+,> for Open settings, the macOS default, so every Linux test leg fails. Build that row from UserConfig::new().keys.open_settings in the test instead.
- The
device_navigationslots are swapped:{up}gets the move_down key (player.rs:1743). - spotatui-gui now parses
--config/-c, and a bare flag stops the launch. I'd drop it and load the language from the default path. - Onboarding errors (onboarding.rs:163) are localized and end up in the log. Keep the logged text in English.
- CONTRIBUTING should say that any text edit needs
cargo test --features guito regenerate strings.json.
… device hint slots, GUI config and onboarding errors
Build the help fixture's Open settings row from the platform default. Put move_up in `{up}` and move_down in `{down}` (the English template lists down first, so the text is unchanged). Drop the GUI's `--config`/`-c` parsing and read the language from the default config path. Keep onboarding errors English, since they end up in the log. Note in CONTRIBUTING that any text edit needs `cargo test --features gui` to regenerate strings.json.
|
Thanks! All five are in the new commit:
|
Route the two strings main added through the table: the Shuffle button's label (gui.shuffle_named, LargeModGames#864) and the missing ALSA default device hint (status.app.audio_backend_no_alsa_default, LargeModGames#861). Add generated_name to the PlaylistInfo built by the LargeModGames#859 test.
Route the settings search box's label and its no-match line (LargeModGames#868) through the table (gui.search_settings, gui.no_settings_match); sections() takes the table after the query.
|
Merged main twice to clear the conflicts. The strings main added in the meantime now come from the table too, with the English text unchanged: the Shuffle button's label (#864), the missing ALSA device hint (#861), and the settings search box and its no-match line (#868). Since this touches 270 files, almost anything that lands on main conflicts with it again. Let me know when you're about to merge and I'll sync it with main right then. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
LargeModGames
left a comment
There was a problem hiding this comment.
All five earlier points are fixed. One new break: the settings channel now sends SettingsPayload, but mobile/app/src/app/settings.tsx still passes it to sections() as a row list, so the Android Settings screen throws on rows.filter. CI doesn't typecheck mobile/. Two small ones: dj/mod.rs:96 and dj/tools.rs:1203 read current_playback_snapshot, so the model can get a translated "Unknown Track"; use tracking_playback_snapshot. Also, the doc comment at network/playback.rs:75 was mangled by the replace.
The Android settings screen reads the rows out of the settings payload. The DJ label, the now_playing tool and the DJ dedupe keys read the tracking snapshot, so the model never sees a translated generated title. Restore a doc comment the string replace mangled.
|
Thanks, all three are fixed in the new commit:
|
LargeModGames
left a comment
There was a problem hiding this comment.
One more like the DJ one: lyrics_state_is_current (plugin_api.rs:876) reads current_playback_snapshot, but the detector keys desired_lyrics_identity on the tracking snapshot. Once local_unknown_track is translated, a plugin's lyrics request on an untagged local file times out. Use tracking_playback_snapshot there.
lyrics_state_is_current compares desired_lyrics_identity, which the detector keys on the tracking snapshot, against the same snapshot, so a translated generated title cannot make a plugin's lyrics request wait forever. The play-count test helper feeds the counter the tracking snapshot like the driver does.
|
Good catch, fixed: I went through every other |
# Summary The first of the Chinese translation PRs that follow #865 (refs #726): the sidebar and the help menu in Simplified Chinese (`zh-Hans`) and Traditional Chinese with Taiwan wording (`zh-Hant`). - `src/core/i18n/sidebar.rs`: 26 of 32 sidebar entries. The other six are product names (Spotify, YouTube, Qobuz, Subsonic, Apple Music, AI DJ) and stay as they are. - `src/core/i18n/help.rs`: 147 of 148 help entries; the remaining one is the AI DJ context name. Key names in descriptions (`<Ctrl+,>`, `Esc`, …) are left untouched. - `gui/src/bindings/strings.json` is regenerated, which is most of the diff. English is unchanged: only the two Chinese tables gain entries, and anything not translated yet still falls back to English. The other areas come next, one PR each. # Testing macOS (aarch64), on top of `02119389`: - `cargo fmt --all --check` and `cargo clippy --locked -- -D warnings`: clean. - `cargo test --locked`: 2168 passed, 8 ignored. The gui-feature run leaves no bindings diff. - New tests in `src/tui/ui/localization_tests.rs` render the Chinese sidebar and help with `TestBackend`: labels fit narrow widths and keep the source gates, the help filter keeps shortcuts aligned, availability hints follow the active source, a no-match filter keeps the typed text literally, and both render in tiny viewports without panicking. # Additional notes The translations were checked by a second pass for wording and Simplified/Traditional consistency. A native-speaker review is welcome; any wording fix is a one-line change in the table. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Localization** * Added Simplified and Traditional Chinese translations for help content, sidebar labels, and empty-state messages. Items without Chinese translations continue to appear in English. * Help screens now display localized headers, shortcut information, and source availability hints when using Chinese. * Improved consistency of Chinese text and layout across filtered help results and different screen sizes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: 2570165831 <[email protected]>
Summary
The first part of #726: user-visible interface text moves into one typed table that the terminal app and the GUI share, plus a language setting. This PR ships the mechanism and the English table only. The Chinese tables come in 12 small follow-up PRs, one area each, so the translations can be reviewed on their own.
Stringstable (src/core/i18n/): plain data, grouped by area (sidebar,help,settings,popups,screens,onboarding,gui,recap,status.{app,infra,runtime,tools}). Messages with values are named templates ("Added to {name}"), and each one has a small typed method, so call sites stay compile-checked (app.strings().status.infra.playlist_added_named(name)). Because the table is plain data it derivesSerializeandts_rs::TS, and the GUI renders the same strings through the generated bindings instead of keeping its own copy.behavior.language:auto(default),en,zh-Hans,zh-Hant, also in Settings (shown as "Auto (system)", saved asauto).autopicks Simplified or Traditional Chinese only when the system language is Chinese, and English for every other language. The system language is read once at startup:LC_ALL/LC_MESSAGES/LANG, then the macOS preferred languages or the Windows UI language (GetUserPreferredUILanguages). Common spellings likezh-CNorzh_TWare accepted; any other value logs a warning and falls back toautoinstead of failing the config load.core/,infra/andruntime/read the table.core/andinfra/still don't importtui. A localized error still logs the original English error and still setsapi_error, so CLI exit codes don't change.infra/dj/tools.rssays why). The DJ's own on-screen summary of a tool result is localized.zh-Hansandzh-Hantcan already be selected, but their tables areStrings { ..EN }, so they show English. The CHANGELOG anddocs/configuration.mdsay so.English output does not change: tests compare every row of the English help table and the default playbar with the previous output, and existing tests keep asserting the same English text (where a function now takes the table, the test passes
&EN).Testing
On macOS (aarch64), commit
7e19588bon top ofe6d22a7d:cargo fmt --all --check: clean.cargo clippy --locked -- -D warningsfor the default build,all-sources, slim (telemetry,tui), headless (telemetry), headless-streaming, mcp-only, ai-dj-only and the gui feature set: all clean.cargo test --locked:LANG=zh_TW.UTF-8, so the suite doesn't depend on the machine's locale)--features all-sources: 2368 passed, 30 ignoredgui/src/bindings/; there is no diff afterwards.gui/:npm ci,npm run lint,npm run format:check,npm run typecheck,npm test(432 tests),npm run build: all pass.Not covered:
ci.ymlhas no Windows leg, anddesktop.ymlbuilds onwindows-latestonly on pushes to main and manual runs, not on PRs. The Windows-only code isnative_language()insrc/core/i18n/locale.rs. I type-checked it with clippy (-D warnings) on its own againstwindows-sys 0.61.2forx86_64-pc-windows-msvc; it hasn't run on a Windows machine.Additional notes
gui/src/bindings/, mostlystrings.json). The rest is the table modules and the call-site changes.src/core/i18n/mod.rs,locale.rsandcore/app/localization.rsare the places to start.windows-sys(Win32_Globalization) under the Windows-only dependencies, and an optionalunicode-segmentationenabled by thetuifeature. Both were already inCargo.lockat the same versions (0.61.2 and 1.12.0); the lockfiles only gain the dependency edges.CONTRIBUTING.mdhas a short "Adding interface text" section). A missing Chinese entry falls back to English, and the testreports_entries_still_in_englishprints the untranslated entries without failing.Refs #726