Project

General

Profile

Bug #569

Qt translations are not included

Added by Thomas Lange over 8 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Minor
Assignee:
-
Category:
libaudqt
Target version:
Start date:
August 20, 2015
Due date:
% Done:

100%

Estimated time:
Affects version:

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.

[1] http://doc.qt.io/qt-5/qtranslator.html

qttranslator.patch (815 Bytes) qttranslator.patch Non-working patch Thomas Lange, August 20, 2015 20:05
qttranslator_v2.patch (1.82 KB) qttranslator_v2.patch Working patch Thomas Lange, January 16, 2021 23:43

History

#1 Updated by Thomas Lange about 3 years ago

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.

Findings
  • 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.
Questions
  • 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...
How to test
  • 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
Things to check
  • 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 about 3 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 about 3 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 about 3 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 about 3 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 about 3 years ago

Sounds great, thanks to you too.

Also available in: Atom PDF