Bug #569
Qt translations are not included
100%
Description
Strings by Audacious are meanwhile all shown localized in the Qt interface.
The translations of Qt itself are not included though.
This can be noticed for example in context menus (lyricwiki-qt, scollbars) and menu items (CTRL).
In theory this should be easy to fix, but the attached patch has no influence.
History
#1 Updated by Thomas Lange almost 4 years ago
- Target version set to 4.1
- File qttranslator_v2.patch qttranslator_v2.patch added
More than 5 years later I have tried again to get this working. :D
I have tested the attached patch successfully on Linux (Arch), macOS and Windows (MSYS environment).
The Windows installer probably won't work out of the box though.
- The translations must be loaded in the interface plugins, not in libaudqt.
- The time when they are loaded absolutely matters. Moving the code into QtIfacePlugin::init() for example does not work.
- Qt 5/6 ship several .qm files for the various modules (qt, qtbase, ...), loading only qt_{locale}.qm is not sufficient.
- Should we use QApplication, QCoreApplication or qApp for installTranslator()?
- Why is it not possible to extract the code into a separate method?
I would like to add a method to libaudqt.h and call it in the plugins.
But strangely enough this did not work...
- Make sure to enable another locale (for example de_DE.UTF-8) in /etc/locale.gen
- Run command locale-gen
- Run Audacious with LC_ALL={locale} audacious
- Menu items should show localized key accelerators (CTRL, Shift, ...)
- Context menus should also be localized
- Lyrics: Right-click on text area
- Search tool: Right-click on search entry
#2 Updated by John Lindgren almost 4 years ago
Thank you for looking into this! I can spend some time before the 4.1 release to debug why calling the same code in libaudqt doesn't work.
Does setting LC_ALL also work for testing this on Windows (which was installed in US English) or is there a different method to change the language there?
#3 Updated by Thomas Lange almost 4 years ago
Does setting LC_ALL also work for testing this on Windows (which was installed in US English) or is there a different method to change the language there?
LC_ALL/LANG works only within the MSYS environment and only affects gettext, not Qt.
To change it for Qt use for example:
// QLocale locale = QLocale::system(); QLocale locale = QLocale::German;
If testing on Arch Linux (IIRC you use it too), make sure to install the package qt5-translations.
#4 Updated by John Lindgren almost 4 years ago
The translations must be loaded in the interface plugins, not in libaudqt.
The time when they are loaded absolutely matters. Moving the code into QtIfacePlugin::init() for example does not work.
I think the issue here is that the QTranslator uninstalls itself on destruction. Thus it worked to declare the QTranslator in run() but not init(), only because run() does not return until the application quits.
#5 Updated by John Lindgren almost 4 years ago
- % Done changed from 0 to 100
- Status changed from New to Closed
I pushed a modified version of your patch (to libaudqt) and also updated the Windows packaging script (merge.sh).
In Arch Linux I tested with LANG=de_DE.UTF-8, and in Windows I installed the German language pack and changed the display language in Settings.
In both cases, all elements of Audacious (including the file dialog) correctly showed up in German.
Thanks for the work on this!
#6 Updated by Thomas Lange almost 4 years ago
Sounds great, thanks to you too.