summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale_unix.cpp
diff options
context:
space:
mode:
authorMike FABIAN <maiku.fabian@gmail.com>2012-06-04 17:53:34 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-06 15:29:34 +0200
commit897e19f95ee91ec21bb9dd9f3157ee7333c9018f (patch)
tree66f35a8c87bc698c17562ab2beba4a22e1bb775e /src/corelib/tools/qlocale_unix.cpp
parent7dfee3ffc5129307217eb949698c5088a4561642 (diff)
Check LANGUAGE as well in QSystemLocale::fallbackLocale
Because QSystemLocale::fallbackLocale() is about UI languages, it makes sense to check LANGUAGE as well if appropriate. Adapt tst_qlocale.cpp accordingly. Suggested by Oswald Buddenhagen. Change-Id: Ib2c9674081809e3251be4e34456b05210eebc010 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qlocale_unix.cpp')
-rw-r--r--src/corelib/tools/qlocale_unix.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index 3602319f67..d46ced463c 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -117,6 +117,19 @@ QLocale QSystemLocale::fallbackLocale() const
lang = qgetenv("LC_MESSAGES");
if (lang.isEmpty())
lang = qgetenv("LANG");
+ // if the locale is the "C" locale, then we can return the language we found here:
+ if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
+ return QLocale(QString::fromLatin1(lang));
+
+ // if the locale is not the "C" locale and LANGUAGE is not empty, return
+ // the first part of LANGUAGE if LANGUAGE is set and has a first part:
+ QByteArray language = qgetenv("LANGUAGE");
+ if (!language.isEmpty()) {
+ language = language.split(':').first();
+ if (!language.isEmpty())
+ return QLocale(QString::fromLatin1(language));
+ }
+
return QLocale(QString::fromLatin1(lang));
}