From ddd33b850bb519174511a34eeda40af69a1f7144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Tue, 1 Apr 2014 15:14:10 +0200 Subject: Do not replace "-" with "_" in .po files This causes problem with .po files whose name contains "-". A nice side effect of this approach is we pass a QLocale to QTranslator, which means it will try to load translations for all "ui languages" [1] instead of just the one returned by QLocale::name(). [1]: http://doc-snapshot.qt-project.org/qt5-stable/qlocale.html#uiLanguages REVIEW: 117296 --- modules/ECMCreateQmFromPoFiles.cmake | 7 ++----- modules/ECMQmLoader.cpp.in | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/ECMCreateQmFromPoFiles.cmake b/modules/ECMCreateQmFromPoFiles.cmake index b383311a..f24090b7 100644 --- a/modules/ECMCreateQmFromPoFiles.cmake +++ b/modules/ECMCreateQmFromPoFiles.cmake @@ -57,11 +57,8 @@ function(_ecm_qm_create_target po_dir pot_name data_install_dir data_install_sub file(GLOB po_files "${po_dir}/*.po") foreach (it ${po_files}) - # PO files are foo-en_GB.po not foo_en_GB.po like Qt expects. Get a - # proper filename. - get_filename_component(it ${it} ABSOLUTE) - get_filename_component(file_with_dash ${it} NAME_WE) - string(REPLACE "-" "_" filename_base "${file_with_dash}") + get_filename_component(filename_base ${it} ABSOLUTE) + get_filename_component(filename_base ${it} NAME_WE) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(tsfile ${CMAKE_CURRENT_BINARY_DIR}/${filename_base}.ts) diff --git a/modules/ECMQmLoader.cpp.in b/modules/ECMQmLoader.cpp.in index 92c0d07a..4fd9c116 100644 --- a/modules/ECMQmLoader.cpp.in +++ b/modules/ECMQmLoader.cpp.in @@ -13,10 +13,9 @@ static QTranslator *createTranslator() QString installSubDir = QStringLiteral("@data_install_sub_dir@"); QString qmName = QStringLiteral("@qm_name@"); - QString lang = QLocale::system().name(); QString dir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, installSubDir, QStandardPaths::LocateDirectory); QTranslator *translator = new QTranslator(QCoreApplication::instance()); - translator->load(qmName + QStringLiteral("_") + lang, dir); + translator->load(QLocale::system(), qmName, QStringLiteral("-") /* prefix */, dir); return translator; } -- cgit v1.2.1