From f98786bc62cc8a0cfe2e39a6a9f7b9abebf04521 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 --- 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; + } } }