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 /modules | |
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 'modules')
-rw-r--r-- | modules/ECMQmLoader.cpp.in | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/ECMQmLoader.cpp.in b/modules/ECMQmLoader.cpp.in index 12a2d146..f636ecc4 100644 --- a/modules/ECMQmLoader.cpp.in +++ b/modules/ECMQmLoader.cpp.in @@ -65,7 +65,12 @@ namespace { QLocale locale = QLocale::system(); if (locale.name() != QStringLiteral("en")) { if (!loadTranslation(locale.name())) { - loadTranslation(locale.bcp47Name()); + if (!loadTranslation(locale.bcp47Name())) { + const int i = locale.name().indexOf(QLatin1Char('_')); + if (i > 0) { + loadTranslation(locale.name().left(i)); + } + } } } } |