diff options
author | Wolfgang Bauer <wbauer@tmo.at> | 2018-01-17 21:55:53 +0100 |
---|---|---|
committer | Wolfgang Bauer <wbauer@tmo.at> | 2018-01-17 21:55:53 +0100 |
commit | 78443e0f0373c2b243d75ac37f891879df8ec08b (patch) | |
tree | a05b441e3f9dad6ea11d46eed6a6aa8fbb2bd47d /tests | |
parent | bf9840ade0606c4a17b1632974ae361dfd7bbf03 (diff) | |
download | extra-cmake-modules-78443e0f0373c2b243d75ac37f891879df8ec08b.tar.gz extra-cmake-modules-78443e0f0373c2b243d75ac37f891879df8ec08b.tar.bz2 |
Fall back to language name for translations lookup if locale name fails
For locales like de_AT, the current code only looks in
share/locale/de_AT/ and share/locale/de-AT/ for translation catalogs,
but not in share/locale/de/ where they most likely are.
That's because bcp47Name() returns "de-AT" for de_AT (though in the
case of de_DE e.g. it does return "de").
This patch additionally tries to fall back to the general language by
taking the part of the locale name before the first '_'.
Differential Revision: https://phabricator.kde.org/D9793
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ECMPoQmToolsTest/check.cmake.in | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index aeef8e42..26320584 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -58,16 +58,20 @@ endif() if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") set(exp_output_catalog_en "english text:english plural form 5") set(exp_output_catalog_de "german text:german plural form 5") + # no de_AT translation -> should fall back to de + set(exp_output_catalog_de_AT "${exp_output_catalog_de}") # no french translation provided -> english fallback set(exp_output_catalog_fr "${exp_output_catalog_en}") set(exp_output_catalog2_en "2nd english text:2nd english plural form 5") set(exp_output_catalog2_de "2nd german text:2nd german plural form 5") + # no de_AT translation -> should fall back to de + set(exp_output_catalog2_de_AT "${exp_output_catalog2_de}") # no french translation provided -> english fallback set(exp_output_catalog2_fr "${exp_output_catalog2_en}") function(check_translations name exec catalog_name) - foreach(lang en de fr) + foreach(lang en de de_AT fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" LANGUAGE=${lang} "${exec}" |