Conversation
|
@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! |
|
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. |
|
@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.
063f094 to
c38479c
Compare
|
@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. |
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>.qmbeside the root QML file, following theQQmlApplicationEnginenaming convention. Applications can useqsTr()and other standard Qt translation APIs, with Qt handling plural forms and translation contexts. SetQt.uiLanguageto switch languages.One
QTranslatoris owned byRootWrapperacross engine reloads, so catalogs from overlapping generations do not mix. Language changes replace the catalog and callretranslate(). 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
popupwindow::moveWithParentfails with the offscreen platform; the same failure was reproduced with the original source during earlier verification.rootwrapper.cppfound identical warnings in unchanged headers before and after this change.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.