Search Unity

Question Localization Startup Lacale problem with sytem language

Discussion in 'Localization Tools' started by Kyle4D, Mar 22, 2022.

  1. Kyle4D

    Kyle4D

    Joined:
    Dec 6, 2014
    Posts:
    6

    I got Language Selection Popup when the game starts for the first time.

    What I am trying to do is to change SelectedLocale to System Language at startup depending on user device's system language as well as to change the flag and text.
    I think it will provide better experience to the user in this way who is not a speaker of the default fallback language --English.

    I wrote scripts for this.And I needs to test that repeatedly switching system languages. My project is in very early stage of the development so building it on a real device and changing language would be really cumbersome because making and getting a certificate, app id, provisioning file will be needed too.

    So, first I needed a way to change the startup language of Unity's Play Mode in 2020.3.30 on macOS.
    Does anyone know how to set it?
    I could not find this, so I decided to use Device Simulator for that matter, which marks my project "Preview Packages in Use".

    Anyway, It has System Language option on Control Panel. thanks to anyone made this. :)


    I ensured that it works with
    Code (CSharp):
    1.  Debug.Log("systemLang: " + Application.systemLanguage);
    But, the Localization package does not pick the system language of it.




    Locale Selector shoud pick up the System Language with System Locale Selector as far as I understand the manual.

    Code (CSharp):
    1. void Start()
    2.     {
    3.         Debug.Log("systemLang: " + Application.systemLanguage);
    4.        
    5.         LocalizationSettings.InitializationOperation.WaitForCompletion();
    6.         Debug.Log("Selected Locale: " + LocalizationSettings.SelectedLocale.LocaleName);
    7.  
    8.       // Do something about popup with SelectedLocale
    9.     }
    I expected SelectedLocale after LocalizationSettings.InitializationOperation, to be the same language as what I have chosen in the Simulator.
    But the result of Log for SelectedLocale.LocaleName is allways "English (en)".

    If I get rid of System Locale Selector and set Specific Locale Selector with other language, for example "German (de)", rather than English, it works with that language: SelectedLocale is "German (de)" and the proper flag is ticked.

    But never works with System Language. What am I doing wrong?
     

    Attached Files:

  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    This looks like a bug. I'll ask QA to look at the device simulator and see if they can reproduce the issue.
    That said, the startup locale is selected differently for some platforms so the simulator may not give an accurate representation.

    The System Language is actually the last thing we try:
    upload_2022-3-22_11-0-7.png
     
  3. Kyle4D

    Kyle4D

    Joined:
    Dec 6, 2014
    Posts:
    6
    Okay... I got a workaround with system languages in an ugly switch statement.. I hope it will be fixed soon.
    And like I said, I hope there's a way to change the startup language for the Play mode. the mobile simulator is a little buggy. Besides PC and Console games need that for the matter of what I was trying to do
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    It's not really a bug, the system selector is working as expected. It's just that the device simulator is changing the system language value and we prioritize other API over this as it's limited in the number of languages it supports. The System Culture is better as it can differentiate between more languages and regional variations. So if we use the System Language value in the simulator we are giving a false impression of how it will actually work on the device because we won't use that value then.
    Ideally you would need to be able to change the culture info value in the simulator as well as the system language. So setting this value in the simulator would not represent the player. We will take a closer look and see if there's a way we can make it work better.

    What do you mean you want to change the startup locale for playmode? You can use the language selector to change it in the editor, if you want it to save the last selected language then you can add the Player Pref Locale selector
     
  5. Kyle4D

    Kyle4D

    Joined:
    Dec 6, 2014
    Posts:
    6
    What I mean with Play Mode is the Unity Player, the Game view window, when 'Build and Run' pressed. if it would be nicer if we can simulate the user's system language changes before Build and Run like Device Simulator does. I think thesting games for PC, Console also need that feature like I originally posted. I am only using Device Simulator because I could not found out that feature with the normal Game view.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Sure. I'll see if we can add some extra simulated values to the device simulator to get this to better reflect the actual devices.