1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

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

This commit is contained in:
Mike Gelfand 2014-12-22 01:08:19 +00:00
parent f83872849a
commit 1eec889832
2 changed files with 39 additions and 4 deletions

View file

@ -147,6 +147,10 @@ include_directories(
${EVENT2_INCLUDE_DIRS} ${EVENT2_INCLUDE_DIRS}
) )
add_definitions(
"-DTRANSLATIONS_DIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${TR_NAME}/translations\""
)
add_executable(${TR_NAME}-qt add_executable(${TR_NAME}-qt
${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_UI_SOURCES} ${${PROJECT_NAME}_UI_SOURCES}
@ -175,3 +179,7 @@ if(INSTALL_DOC)
endif() endif()
install(FILES transmission-qt.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) install(FILES transmission-qt.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
if(ENABLE_NLS)
install(FILES ${${PROJECT_NAME}_QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${TR_NAME}/translations)
endif()

View file

@ -80,6 +80,20 @@ namespace
SESSION_REFRESH_INTERVAL_MSEC = 3000, SESSION_REFRESH_INTERVAL_MSEC = 3000,
MODEL_REFRESH_INTERVAL_MSEC = 3000 MODEL_REFRESH_INTERVAL_MSEC = 3000
}; };
bool
loadTranslation (QTranslator& translator, const QString& name, const QString& localeName,
const QStringList& searchDirectories)
{
const QString filename = name + QLatin1Char ('_') + localeName;
foreach (const QString& directory, searchDirectories)
{
if (translator.load (filename, directory))
return true;
}
return false;
}
} }
MyApp::MyApp (int& argc, char ** argv): MyApp::MyApp (int& argc, char ** argv):
@ -95,13 +109,26 @@ MyApp::MyApp (int& argc, char ** argv):
setApplicationName (MY_CONFIG_NAME); setApplicationName (MY_CONFIG_NAME);
const QString localeName = QLocale ().name ();
// install the qt translator // install the qt translator
qtTranslator.load ("qt_" + QLocale::system ().name (), QLibraryInfo::location (QLibraryInfo::TranslationsPath)); if (loadTranslation (qtTranslator, QLatin1String ("qt"), localeName, QStringList ()
installTranslator (&qtTranslator); << QLibraryInfo::location (QLibraryInfo::TranslationsPath)
#ifdef TRANSLATIONS_DIR
<< TRANSLATIONS_DIR
#endif
<< (applicationDirPath () + "/translations")
))
installTranslator (&qtTranslator);
// install the transmission translator // install the transmission translator
appTranslator.load (QString (MY_CONFIG_NAME) + "_" + QLocale::system ().name (), QCoreApplication::applicationDirPath () + "/translations"); if (loadTranslation (appTranslator, MY_CONFIG_NAME, localeName, QStringList ()
installTranslator (&appTranslator); #ifdef TRANSLATIONS_DIR
<< TRANSLATIONS_DIR
#endif
<< (applicationDirPath () + "/translations")
))
installTranslator (&appTranslator);
Formatter::initUnits (); Formatter::initUnits ();