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 int.ToString("N0") in UWP build localization issue

Discussion in 'Windows' started by big_3, Jan 14, 2023.

  1. big_3

    big_3

    Joined:
    Apr 20, 2016
    Posts:
    86
    Hi,

    I'm using Unity 2022.2.1f and have the following problem.

    When I convert a int to a string with the code:

    int.ToString("N0")

    it always uses English number formatting and does not respect current system locale. For example 109823 will be converted to "109,823". However in Germany e.g. it should be "109.823".

    This only happens in UWP build. In the editor it is converted correctly using the current system locale.

    Is this a known issue? This was an issue in the past and seems to be back.

    Thanks
    Jus
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,438
    If you create a bare UWP application from Visual Studio (without Unity), does it behave correctly?
     
  3. big_3

    big_3

    Joined:
    Apr 20, 2016
    Posts:
    86
    It also returns the string in English (en-US) format. That's strange. I think the reason is, that CultureInfo.CurrentCulture is "en-US" although I have selected German (de-DE) in my regional settings in Windows.

    Is there a way to format an integer according to the regional settings of the operating system? On Android devices it seems to work correctly.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,438
    I suspect you need to declare in the app manifest that you support a language before it will show up: https://learn.microsoft.com/en-us/windows/apps/design/globalizing/manage-language-and-region

    But I'm not 100% sure on this. There are also several settings in Windows for region/languages that are also different for regular Windows applications and UWP applications.

    That said, we have this functionality covered by automated tests so it should be working.