Add i18n support and translations (ko, ja, zh_CN, zh_TW)#1511
Add i18n support and translations (ko, ja, zh_CN, zh_TW)#1511NEWBIE0413 wants to merge 6 commits into
Conversation
|
Really excited to see this! Native i18n support would be a huge improvement — especially for Chinese users who'd love to get proper translations without relying on external scripts. Looking forward to seeing this land. Thanks for the great work! |
QuickShell drives the shell with a bare QQmlEngine and never installs a QTranslator, so qsTr() strings always rendered in English regardless of locale. This adds the missing piece: - TranslationLoader: installs a QTranslator for the system locale, searching the per-user data dir then the system install dir. - A custom QQmlEngineExtensionPlugin for Caelestia.Internal overriding initializeEngine() to load translations at startup. - CMake: compile translations/*.ts to .qm via lrelease and install them where the loader looks; qml_module gains an optional PLUGIN_SOURCE arg. - Wrap previously-hardcoded UI strings (weather, lyrics, kb layout) in qsTr() so they become translatable. The infrastructure is language-agnostic and a graceful no-op when no matching .qm exists.
Translates 638 strings across the shell (bar, dashboard, network/VPN/ bluetooth settings, launcher, lock screen, weather, audio).
Machine-translated drafts covering all 638 strings; community review by native speakers is welcome to refine wording. The i18n infrastructure loads each automatically based on system locale.
b4f2e06 to
7c4e941
Compare
- Format translationloader.cpp per project .clang-format. - Make LinguistTools optional (QUIET) guarded by 'if(TARGET Qt6::lrelease)'; the CI arch-env image lacks it and REQUIRED broke configure. - Store translationDirs() result in a const local to avoid clazy range-loop-detach on the QStringList.
|
Thank you! As a Korean user myself, I'd love to see this PR land too 🙂 Quick status update: I've just rebased onto the latest On the translations: Korean (ko) is reviewed by me as a native speaker, while Japanese and both Chinese variants (zh_CN, zh_TW) are machine-translated drafts — native-speaker review is very welcome to refine the wording. The infrastructure itself is language-agnostic, so adding more languages is just dropping in another |
7c4e941 to
626fdc9
Compare
|
Hi! I'm really excited about this i18n infrastructure. I'd love to contribute by creating and maintaining the official Spanish (es) translation for the shell once this lands! Let me know if I can start working on it. 😄 |
soramanew
left a comment
There was a problem hiding this comment.
This is great! I'll have to do some testing myself, but overall this seems pretty decent.
| # Compile translations (.ts -> .qm) with lrelease and install where | ||
| # TranslationLoader looks. Done via a direct custom command because the shell | ||
| # has no build target for qt_add_translations to attach to. Skipped when | ||
| # LinguistTools is unavailable, so translations are an optional extra. |
There was a problem hiding this comment.
Can we not attach the translations to the module that the translations are loaded from?
There was a problem hiding this comment.
Moved this — translations now attach to the base Caelestia module via the same qml_module helper, instead of the standalone custom command.
There was a problem hiding this comment.
IMO the translator belongs in the base Caelestia module compared to the internal module.
There was a problem hiding this comment.
Done — moved translationloader and the plugin entry point into the base Caelestia module, namespace dropped to caelestia::. Verified it still loads (ko shows up).
Re-extracted against current main (565 strings): covers the new nexus apps page, notification settings, and 2.0 UI changes. Korean reviewed by a native speaker; ja/zh_CN/zh_TW are machine-translated drafts. Also fixes a stray trailing '>' that had crept into zh_TW entries.
Per review: the translator belongs in the base Caelestia module rather than Caelestia.Internal, and the translations attach to the module they're loaded from. Moves translationloader + the custom plugin entry point into the Caelestia module, drops the namespace to caelestia::, and renames the log category to caelestia.i18n.
|
Pushed the review changes — translator + plugin entry point moved into the base Caelestia module, and translations re-extracted against current main so they cover the 2.0 UI (nexus apps page, notification settings, etc). Tested locally, ko loads fine. @MiguxJS that'd be great — once this lands, adding Spanish is just a caelestia_es.ts file, so feel free to start whenever. |
Summary
The shell already wraps user-facing strings in
qsTr(), but there was nomechanism to actually load translations — QuickShell drives the shell with a
bare
QQmlEngineand never installs aQTranslator, soqsTr()strings alwaysrendered in English regardless of locale, and there were no translation files.
This PR adds the missing i18n infrastructure plus initial translations.
Infrastructure (language-agnostic)
TranslationLoaderinstalls aQTranslatorfor the current system locale,searching the per-user data dir (
~/.local/share/caelestia/translations) thenthe system install dir.
QQmlEngineExtensionPluginforCaelestia.InternaloverridesinitializeEngine()to load translations at startup (thenretranslate()).translations/*.ts→.qmvialreleaseand installs themwhere the loader looks.
qml_modulegains an optionalPLUGIN_SOURCEarg so amodule can supply a hand-written plugin entry point.
tooltip) are now wrapped in
qsTr().Graceful no-op when no matching
.qmexists — untranslated locales keep theEnglish source strings. Adding a language is just dropping in
translations/caelestia_<locale>.ts.Translations (638 strings each)
— machine-translated drafts. Community review by native speakers is very
welcome to refine wording; these are functional but not yet natively proofread.
Maintainers: if you'd prefer to merge only the reviewed Korean + infrastructure
and take the other languages separately (or wait for native review), happy to
split — just let me know.
Test Plan
extras;plugin;shell) succeeds; all fourcaelestia_*.qmare produced.qs -p) loads the matching.qmfor the system locale (verified ko + ja),reaches
Configuration Loaded, no crash.en_US) logs a graceful fallback to source strings..tscompile cleanly withlrelease(638 finished, 0 unfinished each).