Mediaelch: System's language not recognized on fresh installation

Created on 17 Jan 2021  路  5Comments  路  Source: Komet/MediaElch

Describe the bug
Downloaded v2.8.4 for Windows. The system never ran MediaElch before. The system's language is German but MediaElch starts in English.

Expected behavior
MediaElch should start in German.

MediaElch Version:

  • [x] 2.8.5-dev (nightly)
  • [x] 2.8.4 stable

Operating System:

  • [x] Windows 10 Home
  • [ ] macOS
  • [ ] Linux (distribution: _._)
bug Windows

All 5 comments

My test when I install 2.8.4 (in Windows 10 Pro)
I will install the 2.8.5 dev

ITEM        2.8.4   (Edit) and 2.8.5_2021-01-15

Movies
TMDb Movies English
TMDb Concerts   English
Universal Music Chinese
Fanart.tv   Bulgarian

Series
TMDb TV     English
The TvDB    English


New Image
After setting the correct language in Settings.
Before and After restarting ME.

Movies
Poster Fanart.tv    Portuguese
Poster TMDb     English
Fanart Fanart.tv    Portuguese
Fanart TMDb     English

Series
Poster Fanart.tv    Portuguese
Poster TheTvDB      English
Fanart Fanart.tv    Portuguese
Fanart TheTvDB      English


Scraper Serie   All Unchecked
Scraper Episode All Unchecked

2.8.5 dev exactly the same as 2.8.4
Windows 10 Pro

To exchange images, Fanart.tv respects what is selected in Settings.
But TMDb and TheTvDB do not respect it.

The good news is that all the translations came. :-)
I can now verify all the mistakes I made.

When I want a different poster than the one I have, I click on the poster and open the window.
Nothing happens when I change the language. They are always the same images.
Perhaps this problem is related.

I found the issue.

A fresh Windows 10 Education installtion for Germany has the following properties:

QLocale::system().uiLanguage() == ("de-DE", "en-US")

After reading https://doc.qt.io/qt-5/qtranslator.html#load-1 I would assume, that Qt looks at following files in the specified order:

  1. MediaElch_de_DE.qm
  2. MediaElch_de.qm
  3. MediaElch_en_US.qm
  4. MediaElch_en.qm
  5. MediaElch.qm

For reference, this is from their documentation (2021-03-02):

click to expand

For example, an application running in the locale with the following ui languages - "es", "fr-CA", "de" might call load(QLocale(), "foo", ".", "/opt/foolib", ".qm"). load() would replace '-' (dash) with '_' (underscore) in the ui language and then try to open the first existing readable file from this list:

    /opt/foolib/foo.es.qm
    /opt/foolib/foo.es
    /opt/foolib/foo.fr_CA.qm
    /opt/foolib/foo.fr_CA
    /opt/foolib/foo.fr.qm
    /opt/foolib/foo.fr
    /opt/foolib/foo.de.qm
    /opt/foolib/foo.de
    /opt/foolib/foo.qm
    /opt/foolib/foo.
    /opt/foolib/foo

However, if I look at the documentation on Woboq: https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qtranslator.cpp.html#746 we can see the Qt actually looks for:

  1. MediaElch_de_DE.qm
  2. MediaElch_en_US.qm
  3. MediaElch_de.qm
  4. MediaElch_en.qm
  5. MediaElch.qm

MediaElch_en_US.qm exists but MediaElch_de_DE.qm does not.

If I delete the en_US version (that I use for plurals), everything is back to normal...

For reference, the code:

click to expand

For example, an application running in the \a locale with the following
\l{QLocale::uiLanguages()}{ui languages} - "es", "fr-CA", "de" might call
load(QLocale(), "foo", ".", "/opt/foolib", ".qm"). load() would
replace '-' (dash) with '_' (underscore) in the ui language and then try to
open the first existing readable file from this list:

\li \c /opt/foolib/foo.es.qm
\li \c /opt/foolib/foo.es
\li \c /opt/foolib/foo.fr_CA.qm
\li \c /opt/foolib/foo.fr_CA
\li \c /opt/foolib/foo.de.qm
\li \c /opt/foolib/foo.de
\li \c /opt/foolib/foo.fr.qm
\li \c /opt/foolib/foo.fr
\li \c /opt/foolib/foo.qm
\li \c /opt/foolib/foo.
\li \c /opt/foolib/foo

This is the relevant code: https://github.com/qt/qtbase/blame/40143c189b7c1bf3c2058b77d00ea5c4e3be8b28/src/corelib/kernel/qtranslator.cpp#L757

See also: https://www.kdab.com/fixing-a-common-antipattern-when-loading-translations-in-qt/?unapproved=153182&moderation-hash=fa9697abc8d8bcf596b0e664d0884f77#comment-153182

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ticao2 picture ticao2  路  4Comments

psonnosp picture psonnosp  路  6Comments

thoroc picture thoroc  路  6Comments

psonnosp picture psonnosp  路  5Comments

dfarin picture dfarin  路  5Comments