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

Not working System Locale Selector

Discussion in 'Localization Tools' started by GooRain, Nov 19, 2020.

  1. GooRain

    GooRain

    Joined:
    Nov 15, 2016
    Posts:
    13
    Hello! I'm using 0.9.0-preview version, and having problem with selecting locale according to system language: it's always selecting "en-US" even if setting system language to other languages.

    i have tried using link.xml with:
    <linker>
    <assembly fullname="Unity.Localization" preserve="all">
    <type fullname="UnityEngine.Localization" preserve="all"/>
    </assembly>
    </linker>
    and
    <linker>
    <assembly fullname="Unity.Localization" preserve="all"/>
    </linker>
     
    Mobazy likes this.
  2. GooRain

    GooRain

    Joined:
    Nov 15, 2016
    Posts:
    13
    Using Unity 2019.4.11f1

    CultureInfo: en-US SystemLanguage:Russian
     
  3. GooRain

    GooRain

    Joined:
    Nov 15, 2016
    Posts:
    13
    This code seems to be working!
    Code (CSharp):
    1.  
    2. private IEnumerator Start()
    3. {
    4.     yield return LocalizationSettings.InitializationOperation;
    5.     var cultureInfo = GetSystemCulture();
    6.     var systemLanguage = GetApplicationSystemLanguage();
    7.  
    8.     Debug.Log($"CultureInfo: {cultureInfo} SystemLanguage:{systemLanguage}");
    9.  
    10.     if (systemLanguage != SystemLanguage.Unknown)
    11.     {
    12.         var locale = LocalizationSettings.AvailableLocales.GetLocale(systemLanguage);
    13.         if (locale != null)
    14.         {
    15.             Debug.Log($"Set Locale: {locale}");
    16.             LocalizationSettings.SelectedLocale = locale;
    17.         }
    18.     }
    19. }
    20.  
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    I think there's a long-standing bug with CultureInfo returning en-US instead of the correct culture.
    Are you using IL2CPP?
     
  5. GooRain

    GooRain

    Joined:
    Nov 15, 2016
    Posts:
    13
    Yes, on iOS we are using IL2CPP.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Ah yes, it sounds like the bug.
     
    GooRain likes this.
  7. fedorenkosergiy

    fedorenkosergiy

    Joined:
    Jun 11, 2014
    Posts:
    8
    Hello,
    looks like the System Locale Selector doesn't work in the package of version 1.2.1 if the target locale can't be converted into a CultureInfo.
    For example, I can't use the Crimean Tatar language (crh). At the same time, Apple does recognize it. The language is included in ISO 639-2 and ISO 639-3 standards
    2022-05-03 23.45.39.jpg
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
  9. AR_Tehcnoplus

    AR_Tehcnoplus

    Joined:
    Jan 17, 2022
    Posts:
    15
    Hey. I have also set Specific locale selector and whenever I start the app it changes to English. The Localization version is 1.3.2

    upload_2022-6-22_14-33-55.png
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    If you want it to use Greek then you need to drag it to be the top or it will only use Greek when the other selectors can not find a locale.
     
  11. AR_Tehcnoplus

    AR_Tehcnoplus

    Joined:
    Jan 17, 2022
    Posts:
    15
    Hey Karl. I did put it on top but it doesnt work. The only way to set it is use something like this at the beginning

    Code (CSharp):
    1.         LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.Greek);
    2.  
    Also there is another strange bug in my application and I am not sure why this is happening. These line cause the program to freeze. I call them in the Start function. This works normally in the android build but not in the iOS one.

    Code (CSharp):
    1.  if (LocalizationSettings.SelectedLocale == LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.English) )
    2.             {
    3.  
    4.                 m_Dropdown.value = 1;
    5.             }
    6.             else
    7.             {
    8.                 m_Dropdown.value = 0;
    9.             }
     
    Last edited: Jun 22, 2022
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    In the screenshot it's not at the top, it needs to be where the command line selector is.

    The pause is likely because you have not waited for the initialization operation to complete and so it's forcing it synchronously.
    Try yielding on LocalizationSettings.InitalizationOperation.

    Are you using 1.3.2?
     
    AR_Tehcnoplus likes this.
  13. AR_Tehcnoplus

    AR_Tehcnoplus

    Joined:
    Jan 17, 2022
    Posts:
    15
    The pause was fixed ! i didn't know that it was an asynchronous operation. Thank you for your help Karl!
     
    karl_jones likes this.