Skip to content

core: load shell translation catalogs - #1081

Open
komagata wants to merge 1 commit into
quickshell-mirror:masterfrom
komagata:feature/qtranslator-support
Open

komagata wants to merge 1 commit into
quickshell-mirror:masterfrom
komagata:feature/qtranslator-support

Conversation

@komagata

@komagata komagata commented Sep 5, 2026

Copy link
Copy Markdown

Summary

Allow applications built with Quickshell to translate their UI using Qt's standard translation system. For example, an Omarchy plugin's strings can be included in the shell's translation catalog.

Without built-in catalog loading, applications need extra integration, such as a C++ QML extension that installs a QTranslator. I tried this in an earlier PoC, but it leaves the application responsible for building and distributing the extension and handling engine reloads. This change handles catalog loading in Quickshell itself.

Load i18n/qml_<language>.qm beside the root QML file, following the QQmlApplicationEngine naming convention. Applications can use qsTr() and other standard Qt translation APIs, with Qt handling plural forms and translation contexts. Set Qt.uiLanguage to switch languages.

One QTranslator is owned by RootWrapper across engine reloads, so catalogs from overlapping generations do not mix. Language changes replace the catalog and call retranslate(). Reloads preserve the selected language and load translations before QML object creation. Failed QML compilation leaves the running shell's translator intact.

Related to #445.

Testing

  • Built with Qt 6.11.2 and Clang 22.1.8, with tests enabled, PCH disabled and the crash handler disabled.
  • Added one integration test covering startup translation, Russian plural forms, language switching and source-text fallback.
  • The full suite passes 9 of 10 test targets. popupwindow::moveWithParent fails with the offscreen platform; the same failure was reproduced with the original source during earlier verification.
  • Formatting checks and clang-tidy on the new test pass. Earlier comparison of clang-tidy diagnostics for rootwrapper.cpp found identical warnings in unchanged headers before and after this change.
  • Qt 6.6, Nix, upstream CI and tidyfox have not been verified locally.

Test QML and translation data are separate fixtures. Qt Linguist Tools (lrelease) are required for test builds only; no runtime dependency is added.

Scope

One catalog per shell. Updating a catalog requires an explicit shell reload. Per-plugin catalogs, RTL layout and OS locale settings are outside this change.

Developed with AI assistance.

@komagata

Copy link
Copy Markdown
Author

@outfoxxed When you have a moment, could you let us know whether this approach to loading translation catalogs fits Quickshell's intended direction?

I'd like to move forward with Qt-based i18n in Omarchy, and this proposal would provide the foundation. Other shell developers have also expressed interest in the standard Qt workflow in #445, and all 30 Nix CI checks are currently passing.

Even a brief indication of the preferred API or design, ahead of a detailed review, would help us plan the next steps. Thanks!

@outfoxxed

Copy link
Copy Markdown
Member

I have no issue with the intention of adding translation support, but I need to look into the stability of translation contexts and if we should be using qtranslator here or something else.

@komagata

Copy link
Copy Markdown
Author

@outfoxxed Thanks for your reply! What alternatives to QTranslator are you considering?

Load i18n/qml_<language>.qm with QTranslator and refresh translation
bindings when Qt.uiLanguage changes. Keep catalogs on RootWrapper across
engine reloads and preserve the selected language.

Support an optional i18n/qml.qm source-language catalog for fallback
translations and plurals. Remove translators before application teardown.

Add integration coverage for startup translation, plural forms, language
switching, source-language fallback, and clean shutdown.

Developed with AI assistance.
@komagata
komagata force-pushed the feature/qtranslator-support branch from 063f094 to c38479c Compare September 21, 2026 08:28
@komagata

Copy link
Copy Markdown
Author

@outfoxxed Please let me know if there is anything I can do to help move this forward. I would be happy to investigate alternatives, test approaches, or help with anything else you need.

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.

2 participants