Browse Source

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.

tags/2021-05-28
jules 11 years ago
parent
commit
4721d75cc1
2 changed files with 14 additions and 4 deletions
  1. +11
    -3
      modules/juce_core/native/juce_win32_SystemStats.cpp
  2. +3
    -1
      modules/juce_core/system/juce_SystemStats.h

+ 11
- 3
modules/juce_core/native/juce_win32_SystemStats.cpp View File

@@ -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;
}

+ 3
- 1
modules/juce_core/system/juce_SystemStats.h View File

@@ -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();


Loading…
Cancel
Save