From faae2973ac425288eb61280c0270da657aa82803 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 9 Mar 2016 11:24:01 +0100 Subject: [PATCH] Fixed: With new iOS versions (and perhaps OS X), locale can contains country code --HG-- branch : develop --- code/nel/src/misc/i18n.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 427c102da..d049a7ca3 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -306,11 +306,20 @@ std::string CI18N::getSystemLanguageCode () CFRelease(langCF); } - // only keep language code if supported by NeL - if (!lang.empty() && isLanguageCodeSupported(lang)) + if (!lang.empty()) { - s_cachedSystemLanguage = lang; - break; + // fix language code if country is specified + std::string::size_type pos = lang.find('-'); + + if (pos != std::string::npos) + lang = lang.substr(0, pos); + + // only keep language code if supported by NeL + if (isLanguageCodeSupported(lang)) + { + s_cachedSystemLanguage = lang; + break; + } } }