diff options
author | Ilya Zverev <zverik@textual.ru> | 2016-08-12 19:17:06 +0300 |
---|---|---|
committer | Ilya Zverev <zverik@textual.ru> | 2016-10-07 17:36:03 +0300 |
commit | aa1dd61dcdb109eef16111962c9c0edb48a4938c (patch) | |
tree | d10aaa901faab7a8d8af4dff217ac4498a5a24c1 /platform/preferred_languages.cpp | |
parent | 09566c5ca7aa761a40b0e769e4e44b85c5c3f429 (diff) |
Feature list tool
Diffstat (limited to 'platform/preferred_languages.cpp')
-rw-r--r-- | platform/preferred_languages.cpp | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/platform/preferred_languages.cpp b/platform/preferred_languages.cpp index b2dba2ad0f..77712b8e9d 100644 --- a/platform/preferred_languages.cpp +++ b/platform/preferred_languages.cpp @@ -47,17 +47,38 @@ namespace languages void GetSystemPreferred(vector<string> & languages) { +#if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE) || defined(OMIM_OS_LINUX) + // check environment variables + char const * p = getenv("LANGUAGE"); + if (p && strlen(p)) // LANGUAGE can contain several values divided by ':' + { + string const str(p); + strings::SimpleTokenizer iter(str, ":"); + for (; iter; ++iter) + languages.push_back(*iter); + } + else if ((p = getenv("LC_ALL"))) + languages.push_back(p); + else if ((p = getenv("LC_MESSAGES"))) + languages.push_back(p); + else if ((p = getenv("LANG"))) + languages.push_back(p); + #if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE) - // Mac and iOS implementation - CFArrayRef langs = CFLocaleCopyPreferredLanguages(); - char buf[30]; - for (CFIndex i = 0; i < CFArrayGetCount(langs); ++i) + else { - CFStringRef strRef = (CFStringRef)CFArrayGetValueAtIndex(langs, i); - CFStringGetCString(strRef, buf, 30, kCFStringEncodingUTF8); - languages.push_back(buf); + // Mac and iOS implementation + CFArrayRef langs = CFLocaleCopyPreferredLanguages(); + char buf[30]; + for (CFIndex i = 0; i < CFArrayGetCount(langs); ++i) + { + CFStringRef strRef = (CFStringRef)CFArrayGetValueAtIndex(langs, i); + CFStringGetCString(strRef, buf, 30, kCFStringEncodingUTF8); + languages.push_back(buf); + } + CFRelease(langs); } - CFRelease(langs); +#endif #elif defined(OMIM_OS_WINDOWS) // if we're on Vista or above, take list of preferred languages @@ -100,26 +121,6 @@ void GetSystemPreferred(vector<string> & languages) } } -#elif defined(OMIM_OS_LINUX) - // check environment variables - char const * p = getenv("LANGUAGE"); - if (p && strlen(p)) // LANGUAGE can contain several values divided by ':' - { - string const str(p); - strings::SimpleTokenizer iter(str, ":"); - while (iter) - { - languages.push_back(*iter); - ++iter; - } - } - else if ((p = getenv("LC_ALL"))) - languages.push_back(p); - else if ((p = getenv("LC_MESSAGES"))) - languages.push_back(p); - else if ((p = getenv("LANG"))) - languages.push_back(p); - #elif defined(OMIM_OS_ANDROID) languages.push_back(GetAndroidSystemLanguage()); |