Do not bundle translations with a binary, package them to system dir and use %lang tagging in package. some paths debug: qWarning() << "language: " << language; qWarning() << "qtpath: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath); qWarning() << "apppath: " << a.applicationDirPath(); qWarning() << "curdir: " << QDir::currentPath(); TODO: add install target TODO: make it configurable via cmake params. Author: Elan Ruusamäe --- clementine-0.5.3/src/main.cpp~ 2010-10-18 23:59:12.000000000 +0300 +++ clementine-0.5.3/src/main.cpp 2010-10-18 23:59:15.876170584 +0300 @@ -176,7 +176,7 @@ // Resources Q_INIT_RESOURCE(data); - Q_INIT_RESOURCE(translations); + //Q_INIT_RESOURCE(translations); // Has the user forced a different language? QString language = options.language(); @@ -187,9 +187,15 @@ } // Translations + // Qt: system path LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language); + // Clementine: system path + LoadTranslation("clementine", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language); + // Clementine: QRC LoadTranslation("clementine", ":/translations", language); + // Clementine: application path LoadTranslation("clementine", a.applicationDirPath(), language); + // Clementine: current dir LoadTranslation("clementine", QDir::currentPath(), language); // Icons --- clementine-0.5.3/src/ui/settingsdialog.cpp~ 2010-10-19 11:24:36.488320486 +0300 +++ clementine-0.5.3/src/ui/settingsdialog.cpp 2010-10-19 11:24:40.594127569 +0300 @@ -93,15 +93,22 @@ // Populate the language combo box. We do this by looking at all the // compiled in translations. - QDir dir(":/translations/"); - QStringList codes(dir.entryList(QStringList() << "*.qm")); - QRegExp lang_re("^clementine_(.*).qm$"); - foreach (const QString& filename, codes) { - // The regex captures the "ru" from "clementine_ru.qm" - if (!lang_re.exactMatch(filename)) +// QDir dir(":/translations/"); + QDir localeDir(QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + foreach (const QString& code, dirList) { + if (!QFile::exists(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/" + code + "/LC_MESSAGES/clementine.qm")) { continue; + } - QString code = lang_re.cap(1); +// QStringList codes(dir.entryList(QStringList() << "*.qm")); +// QRegExp lang_re("^clementine_(.*).qm$"); +// foreach (const QString& filename, codes) { +// // The regex captures the "ru" from "clementine_ru.qm" +// if (!lang_re.exactMatch(filename)) +// continue; + +// QString code = lang_re.cap(1); QString name = QString("%1 (%2)").arg( QLocale::languageToString(QLocale(code).language()), code); --- clementine-0.5.3/cmake/Translations.cmake 2010-10-18 23:59:53.487509786 +0300 +++ clementine-0.5.3/cmake/Translations.cmake 2010-10-19 01:42:52.112825900 +0300 @@ -65,10 +65,22 @@ - # Generate a qrc file for the translations - set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc) - file(WRITE ${_qrc} "") - foreach(_lang ${ADD_PO_LANGUAGES}) - file(APPEND ${_qrc} "${po_prefix}${_lang}.qm") - endforeach(_lang) - file(APPEND ${_qrc} "") - qt4_add_resources(${outfiles} ${_qrc}) + # install .qm + set(_potBasename "clementine") + foreach (_lang ${ADD_PO_LANGUAGES}) + set(_qm_filename "clementine_${_lang}.qm") + set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}") + + install(FILES ${_qm_filepath} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.qm) + set(_gmoFiles ${_gmoFiles} ${_gmoFile}) + endforeach (_lang) + + add_custom_target(translations ALL DEPENDS ${_gmoFiles}) + +# # Generate a qrc file for the translations +# set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc) +# file(WRITE ${_qrc} "") +# foreach(_lang ${ADD_PO_LANGUAGES}) +# file(APPEND ${_qrc} "${po_prefix}${_lang}.qm") +# endforeach(_lang) +# file(APPEND ${_qrc} "") +# qt4_add_resources(${outfiles} ${_qrc}) endmacro(add_po)