Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: Fix translation loading, use all paths #606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

digitalcircuit
Copy link
Contributor

@digitalcircuit digitalcircuit commented May 14, 2022

In short

  • Fix QTranslator loading Qt translations on Linux
  • Load translations from all available translation data directories
    • Fixes failure to load translations on Windows due to Qt translation install path
    • Always includes internal resource when present (:/i18n/)
Criteria Rank Reason
Impact ★★★ 3/3 Fixes missing translations on Windows
Risk ★★☆ 2/3 Modifies translation search/load code, macOS untested
Intrusiveness ★☆☆ 1/3 Small set of changes, shouldn't interfere with other pull requests

Details

As of 0.14.0, the Windows installer for Quassel places the Qt translations into C:\Program Files\Quassel IRC\translations folder, while Quassel's own translations are bundled internally in :/i18n/.

Before this change, Quassel would only try to load translations from one possible data path, missing the bundled translations in :/i18n/.

After this change, Quassel tries to load translations from all available data paths, including the bundled translations when present.

Testing

Steps

  1. Build and install Quassel
    • On Windows, download the Windows.zip artifact from GitHub Actions
  2. Open the configuration window
    • Go to SettingsConfigure Quassel…
    • Or, press F7
  3. Expand the Language: drop-down, check that expected languages are present
  4. Select a different language, apply
  5. Restart Quassel
  6. Check if the language applied successfully

Before

Linux

Qt translations fail to load according to the false return status of qtTranslator->load(…) with QLibraryInfo::location(QLibraryInfo::TranslationsPath).

Windows

All translations fail to load.

The Language: setting in the configuration window displays <Untranslated>, <System Default>, and C as the only options.

Screenshot of the Quassel IRC client window in English showing the "Configure Quassel..." window with the "Language" dropdown expanded revealing a lack of translations.

After

Linux

Qt translations successfully load according to the true return status of qtTranslator->load(…) with QLibraryInfo::location(QLibraryInfo::TranslationsPath).

NOTE: For unknown reasons, even when Qt claims the translation loaded successfully, system strings (e.g. the Cancel button) does not get translated. Quassel's strings change successfully. This is not a regression as the same issue happens on the master branch.

Windows

Translations load and apply to both Quassel's strings and Qt's system strings (e.g. the Cancel button).

The Language: setting in the configuration window displays all the expected language options.

The Debug Log window now prints the following debug message:

Translation paths: "C:/Program Files/Quassel IRC\translations/", ":/i18n/", with Qt fallback: "C:/Program Files/Quassel IRC/translations"

Screenshot of the Quassel IRC client window in German showing the "Configure Quassel..." window with the "Language" dropdown expanded, showing a full list of translations as expected.

Fix non-macOS usage of QTranslator to specify the directory properly,
instead of treating it as the prefix.  Continue to search via filename
instead of prefix.

Fixes loading Qt (not Quassel) translations on Ubuntu 20.04 LTS.

See: https://doc.qt.io/qt-5/qtranslator.html#load-1
Versus: https://doc.qt.io/qt-5/qtranslator.html#load

Load translations from all available translation data directories, not
just the first one found.  Always include the internal resource when
present.

NOTE: This removes the ability to disable translations by creating an
empty directory.  The "C" locale should be specified to specifically
disable translation.

Fixes failure to load translations on Windows due to Qt translations
being installed in the Quassel data directory, separate from the
internal bundled Quassel translations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant