From 4721d75cc1bb77667f7685bd4e428eed5178cb58 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 9 May 2014 11:40:04 +0100 Subject: [PATCH] Clarified documentation for SystemStats::getDisplayLanguage(), to make clear that it may return a multi-part region name. Updated the win32 implementation of this method to include the region code. --- .../juce_core/native/juce_win32_SystemStats.cpp | 14 +++++++++++--- modules/juce_core/system/juce_SystemStats.h | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index 6bac9af041..86f105168f 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -428,8 +428,16 @@ String SystemStats::getDisplayLanguage() DynamicLibrary dll ("kernel32.dll"); JUCE_LOAD_WINAPI_FUNCTION (dll, GetUserDefaultUILanguage, getUserDefaultUILanguage, LANGID, (void)) - if (getUserDefaultUILanguage != nullptr) - return getLocaleValue (MAKELCID (getUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SISO639LANGNAME, "en"); + if (getUserDefaultUILanguage == nullptr) + return "en"; - return "en"; + const DWORD langID = MAKELCID (getUserDefaultUILanguage(), SORT_DEFAULT); + + String mainLang (getLocaleValue (langID, LOCALE_SISO639LANGNAME, "en")); + String region (getLocaleValue (langID, LOCALE_SISO3166CTRYNAME, nullptr)); + + if (region.isNotEmpty()) + mainLang << '-' << region; + + return mainLang; } diff --git a/modules/juce_core/system/juce_SystemStats.h b/modules/juce_core/system/juce_SystemStats.h index d9132f5af3..833bf5a09b 100644 --- a/modules/juce_core/system/juce_SystemStats.h +++ b/modules/juce_core/system/juce_SystemStats.h @@ -118,7 +118,9 @@ public: static String getUserRegion(); /** Returns the user's display language. - The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2) + The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2). + Note that depending on the OS and region, this may also be followed by a dash + and a sub-region code, e.g "en-GB" */ static String getDisplayLanguage();