Bug 1111323

Summary: transmission-qt: try to load translations from app executable directory which is /usr/bin on openSUSE
Product: [openSUSE] openSUSE Tumbleweed Reporter: Marguerite Su <i>
Component: GNOMEAssignee: E-mail List <gnome-bugs>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: debug patch to see the internal variables in qt/Application.cc
the fix
fix for 2.84 in Leap 42.3

Description Marguerite Su 2018-10-10 08:03:18 UTC
Created attachment 785578 [details]
debug patch to see the internal variables in qt/Application.cc

Hi,

with transmission-qt-lang 2.94-1.4 installed, transmission-qt can't recognize and load .qm translations properly.

strace transmission-qt:

access("/usr/bin/translations/transmission_zh_CN.qm", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission_zh_CN", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission_zh.qm", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission_zh", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission.qm", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission_en.qm", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission_en", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission.qm", R_OK) = -1 ENOENT
access("/usr/bin/translations/transmission", R_OK) = -1 ENOENT
access("/usr/share/qt5/translations/qt_en.qm", R_OK) = 0

As I see, transmission-qt tries to load translation from /usr/bin/translations (which does not exist and should not exist), then load qt_en.qm from standard qt5 translations directory.

I made a debug build myself(patch included in attachment), and found:

QLibraryInfo::TranslationsPath: "/usr/share/qt5/translations"
applicationDirPath: "/usr/bin"
qtQmDirs: ("/usr/share/qt5/translations", "/usr/bin/translations")
appQmDirs: ("/usr/bin/translations")

and its original code:

void
Application::loadTranslations ()
{ 
  const QStringList qtQmDirs = QStringList () <<
    QLibraryInfo::location (QLibraryInfo::TranslationsPath) <<
#ifdef TRANSLATIONS_DIR
    QString::fromUtf8 (TRANSLATIONS_DIR) <<
#endif
    (applicationDirPath () + QLatin1String ("/translations"));
  
  const QStringList appQmDirs = QStringList () <<
#ifdef TRANSLATIONS_DIR
    QString::fromUtf8 (TRANSLATIONS_DIR) <<
#endif
    (applicationDirPath () + QLatin1String ("/translations"));
  
  QString localeName = QLocale ().name ();
  
  if (!loadTranslation (myAppTranslator, MY_CONFIG_NAME, localeName, appQmDirs))
    { 
      localeName = QLatin1String ("en");
      loadTranslation (myAppTranslator, MY_CONFIG_NAME, localeName, appQmDirs);
    }
  
  if (loadTranslation (myQtTranslator, QLatin1String ("qt"), localeName, qtQmDirs))
    installTranslator (&myQtTranslator);
  installTranslator (&myAppTranslator);
}

if it can't load application translation from appQmDirs("/usr/bin/translations"), it'll try to load english "translation" from the same directory, then try to load standard "qt" translations from qtQmDirs("/usr/share/qt5/translations", "/usr/bin/translations").

none of these can get a perfect hit. because on openSUSE and most of the Linux distributions, qmake will install translations into qt5 standard translations directory /usr/share/qt5/translations.

So I think upstream may didn't test properly on Linux, because on Windows and OSX, applications can have their own directory, eg Apps/Transmission, then Apps/Transmission/translations makes sense.

Marguerite
Comment 1 Marguerite Su 2018-10-10 08:17:36 UTC
Created attachment 785585 [details]
the fix

This patch append QLibraryInfo::location (QLibraryInfo::TranslationsPath) into appQmDirs, so transmission-qt will search translations in our standard Qt translation directory /usr/share/qt5/translations, where our translations are installed.
Comment 2 Marguerite Su 2018-10-10 08:19:01 UTC
https://build.opensuse.org/request/show/640959

fixed.
Comment 3 Marguerite Su 2018-10-11 09:55:10 UTC
Created attachment 785738 [details]
fix for 2.84 in Leap 42.3
Comment 4 Marguerite Su 2018-10-11 09:58:09 UTC
https://github.com/transmission/transmission/issues/736

upstream bug report for reference.

As the upstream and I discussed in that issue, we should use cmake to build transmission instead of patching actual code to "fix". Because currenly transmission is the only application that install its translations into /usr/share/qt5/translations, which should be the directory for Qt only.

I'll switch the specfile from autotools to cmake to see everything okay.
Comment 5 Swamp Workflow Management 2018-10-13 04:30:06 UTC
This is an autogenerated message for OBS integration:
This bug (1111323) was mentioned in
https://build.opensuse.org/request/show/641770 15.0+42.3+Backports:SLE-15 / transmission
Comment 6 Swamp Workflow Management 2018-10-15 13:20:10 UTC
This is an autogenerated message for OBS integration:
This bug (1111323) was mentioned in
https://build.opensuse.org/request/show/642055 15.0+42.3+Backports:SLE-15 / transmission
Comment 7 Swamp Workflow Management 2018-10-17 12:40:09 UTC
This is an autogenerated message for OBS integration:
This bug (1111323) was mentioned in
https://build.opensuse.org/request/show/642596 Factory / transmission
Comment 8 Swamp Workflow Management 2018-10-23 01:15:06 UTC
openSUSE-RU-2018:3303-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 1111323
CVE References: 
Sources used:
openSUSE Leap 42.3 (src):    transmission-2.84-9.3.1
openSUSE Leap 15.0 (src):    transmission-2.94-lp150.2.3.1
openSUSE Backports SLE-15 (src):    transmission-2.94-bp150.3.3.1