Bug? Getting the preferred language of a user & SystemStats::getUserLanguage()

Hi

In the latest version of JUCE SystemStats::getDisplayLanguage() and SystemStats::getUserLanguage() are not getting the preferred language of the user in Windows 10 or 11.

getUserLanguage() is getting the locale and getDisplayLanguage() is displaying the installed languages of the operating system (Windows display language).

More info at: https://stackoverflow.com/a/73551640

In Windows the language settings for Apps look like this:

So in my opinion this is the value that SystemStats::getUserLanguage() should return. This value can be retrieved with the following code:

#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.System.UserProfile.h>
#pragma comment(lib, "windowsapp")

using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::System::UserProfile;

for (const auto& lang : GlobalizationPreferences::Languages())
{
  language_code = String(lang.c_str());
  break;
}

I have just tested it. It seems that:

  • On Windows, getDisplayLanguage() returns the “Windows Display Language”
  • On macOS, getDisplayLanguage() returns the first “Preferred Language”

Hi,

Thanks zsliu98. I’m getting the same results. I had more time to test today. I confirm for Windows that JUCE in its latest code (develop) doesn’t provide a method to return the user preferred language in Windows.

Proposal for the JUCE team: what do you think about making SystemStats::getUserLanguage() return the preferred language for the user and renaming the current SystemStats::getUserLanguage() as “SystemStats::getUserLocale()” to avoid any confusions?