Mojave SystemStats::getLanguage() returning "en" for all languages


#1

Just noticed on Mojave my plug-in fails to switch to selected language when OS preference is updated. Yes, attempted reboot after language change too. The offending call is:

auto currentLocaleAbbrev = SystemStats::getUserLanguage();

Under Mojave, this call is returning “en” for all languages. Prior to Mojave, this call returned the 2-letter language abbreviation for the selected language. I will update code to use getDisplayLanguage() as this call appears to still be functioning as expected.


#2

Are you sure SystemStats::getUserLanguage() is returning an incorrect string? This test app is displaying the correct language when I change it via the system settings:

/*******************************************************************************
 The block below describes the properties of this PIP. A PIP is a short snippet
 of code that can be read by the Projucer and used to generate a JUCE project.

 BEGIN_JUCE_PIP_METADATA

  name:             MojaveLanguageTest

  dependencies:     juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
  exporters:        xcode_mac

  moduleFlags:      JUCE_STRICT_REFCOUNTEDPOINTER=1

  type:             Component
  mainClass:        MyComponent

 END_JUCE_PIP_METADATA

*******************************************************************************/

#pragma once


//==============================================================================
class MyComponent   : public Component,
                      private Timer
{
public:
    //==============================================================================
    MyComponent()
    {
        startTimer (1000);
        
        setSize (600, 400);
    }

    ~MyComponent()
    {
    }

    //==============================================================================
    void paint (Graphics& g) override
    {
        // (Our component is opaque, so we must completely fill the background with a solid colour)
        g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));

        g.setFont (Font (16.0f));
        g.setColour (Colours::white);
        g.drawText ("Hello World!", getLocalBounds(), Justification::centred, true);
    }

    void resized() override
    {
        // This is called when the MyComponent is resized.
        // If you add any child components, this is where you should
        // update their positions.
    }


private:
    //==============================================================================
    void timerCallback() override
    {
        DBG ("User language = "    + SystemStats::getUserLanguage());
        DBG ("Display language = " + SystemStats::getDisplayLanguage());
    }
    
    //==============================================================================
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyComponent)
};