Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Application.SystemLanguage does not return Windows Display Language

Discussion in 'Scripting' started by NVriezen, Jul 18, 2023.

  1. NVriezen

    NVriezen

    Joined:
    Oct 5, 2015
    Posts:
    45
    Hello,

    I'm doubting if this is by design or if this is a bug.
    However the Application.systemLanguage variable does not return the display language on Windows in Unity 2021.3.20f1.

    An example:
    I go to the Language Settings on Windows and change the Windows Display Language to English.
    Then I go to Region Settings and change the Country to the Netherlands and the Regional Format to Japanese.

    When I now boot our game, the returned value from Application.systemLanguage is Japanese.
    While I expect it to be English as that is the language that Windows is set to display.

    Is it intended that Japanese is returned?
    Or is this indeed a bug?
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Try the Locale Selector as advised here
     
  3. NVriezen

    NVriezen

    Joined:
    Oct 5, 2015
    Posts:
    45
    Thanks for the suggestion. However that doesn't change the behaviour I'm seeing.
    I rather use Application.systemLanguage than a different feature. As our tools are built based on the Application.systemLanguage variable.
     
  4. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Unity gets Application.systemLanguage from Windows with certain call, I read that it's like 2 lines of code. Whatever Windows returns is up to Windows, this might change between Windows versions. So by not using the locales, you are definitely creating platform dependence to your game and can't blame Unity for it cos it's Windows domain.
     
  5. NVriezen

    NVriezen

    Joined:
    Oct 5, 2015
    Posts:
    45
    I understand it can be a Windows change. But then it's intended behaviour.
    So I am wondering if it is indeed the case and we just have to fix our tools in the future.
    Or if it is an actual bug on Unity's side.
    I don't have the source code of Unity so I don't know what those two lines of code are.

    Besides that, if the behaviour changed through a Windows update.
    Then I expect the documentation to be updated, since Application.systemLanguage does not actually return a language anymore in that case. It returns a regional format disguised as a language.
    So a note about this would help anyone else trying to use this variable in the future.
     
  6. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    I don't think you understand how complicated system language selection settings really are. Systems don't just work the way that they give you a single value. The values they provide are platform-dependent and multi-layered. So the Unity locale selection solution is like a multi-step selection process, "If this exists, then use it, otherwise use this".

    It's not a bug and this has been discussed before
     
  7. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Basically Unity is calling Windows API and asking it to return a value. This value can be configured in many places in Windows, and some values can exist, some not exist and some can override others. Windows goes through those values and decides what to return.