aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAurélien Gâteau <agateau@kde.org>2014-04-01 15:14:10 +0200
committerAurélien Gâteau <agateau@kde.org>2014-04-01 15:38:32 +0200
commitddd33b850bb519174511a34eeda40af69a1f7144 (patch)
tree21d1caad4154d28621fb7f8f3789aef1d0cf99c7 /modules
parent74875c5e91dcd6be34504fa5f02eb3c4978ce245 (diff)
downloadextra-cmake-modules-ddd33b850bb519174511a34eeda40af69a1f7144.tar.gz
extra-cmake-modules-ddd33b850bb519174511a34eeda40af69a1f7144.tar.bz2
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
Diffstat (limited to 'modules')
-rw-r--r--modules/ECMCreateQmFromPoFiles.cmake7
-rw-r--r--modules/ECMQmLoader.cpp.in3
2 files changed, 3 insertions, 7 deletions
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;
}