From 78443e0f0373c2b243d75ac37f891879df8ec08b Mon Sep 17 00:00:00 2001 From: Wolfgang Bauer Date: Wed, 17 Jan 2018 21:55:53 +0100 Subject: 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 --- modules/ECMQmLoader.cpp.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/ECMQmLoader.cpp.in') 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)); + } + } } } } -- cgit v1.2.1