Changeset 14396


Ignore:
Timestamp:
Dec 22, 2014, 1:08:19 AM (8 years ago)
Author:
mikedld
Message:

#4050: Use TRANSLATIONS_DIR macro as a hint for Qt client translation files location

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/CMakeLists.txt

    r14393 r14396  
    148148)
    149149
     150add_definitions(
     151    "-DTRANSLATIONS_DIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${TR_NAME}/translations\""
     152)
     153
    150154add_executable(${TR_NAME}-qt
    151155    ${${PROJECT_NAME}_SOURCES}
     
    176180
    177181install(FILES transmission-qt.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
     182
     183if(ENABLE_NLS)
     184    install(FILES ${${PROJECT_NAME}_QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${TR_NAME}/translations)
     185endif()
  • trunk/qt/app.cc

    r14394 r14396  
    8181    MODEL_REFRESH_INTERVAL_MSEC   = 3000
    8282  };
     83
     84  bool
     85  loadTranslation (QTranslator& translator, const QString& name, const QString& localeName,
     86                   const QStringList& searchDirectories)
     87  {
     88    const QString filename = name + QLatin1Char ('_') + localeName;
     89    foreach (const QString& directory, searchDirectories)
     90    {
     91      if (translator.load (filename, directory))
     92        return true;
     93    }
     94
     95    return false;
     96  }
    8397}
    8498
     
    96110  setApplicationName (MY_CONFIG_NAME);
    97111
     112  const QString localeName = QLocale ().name ();
     113
    98114  // install the qt translator
    99   qtTranslator.load ("qt_" + QLocale::system ().name (), QLibraryInfo::location (QLibraryInfo::TranslationsPath));
    100   installTranslator (&qtTranslator);
     115  if (loadTranslation (qtTranslator, QLatin1String ("qt"), localeName, QStringList ()
     116        << QLibraryInfo::location (QLibraryInfo::TranslationsPath)
     117#ifdef TRANSLATIONS_DIR
     118        << TRANSLATIONS_DIR
     119#endif
     120        << (applicationDirPath () + "/translations")
     121      ))
     122    installTranslator (&qtTranslator);
    101123
    102124  // install the transmission translator
    103   appTranslator.load (QString (MY_CONFIG_NAME) + "_" + QLocale::system ().name (), QCoreApplication::applicationDirPath () + "/translations");
    104   installTranslator (&appTranslator);
     125  if (loadTranslation (appTranslator, MY_CONFIG_NAME, localeName, QStringList ()
     126#ifdef TRANSLATIONS_DIR
     127        << TRANSLATIONS_DIR
     128#endif
     129        << (applicationDirPath () + "/translations")
     130      ))
     131    installTranslator (&appTranslator);
    105132
    106133  Formatter::initUnits ();
Note: See TracChangeset for help on using the changeset viewer.