Search Unity

Localization Won't Change From English When Running Outside Of Editor

Discussion in 'Localization Tools' started by thedollargamestore, Oct 21, 2021.

  1. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Hi,

    I'm rather stumped at the moment. I initially had a problem where the localization wouldn't load any strings at all. After marking the localization asset as addressable and rerunning the addressable build and analyze tool it worked. I then proceeded to add 6 more languages to the game, and on the menu depending on the flag you click I set the selected locale with the following line:

    Code (CSharp):
    1. LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(locale);
    2.  
    3. //locale being passed in as either "en" or "ar" etc.
    It works fine in the editor, but when I build the project and run it, it always seems to present the English translation no matter which option I pick.

    To top it off, I'm running into these "Unfixable" issues and I can't seem to find any solutions online.


    Assistance would be greatly appreciated. The client's deadline is around the corner and I'm quite desperate for an answer at this point.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    After marking the localization asset as addressable
    What asset? Don't mark the Localization settings asset as addressable, it does not need it and may be the reason for things going wrong. You may end up with 2 Localization settings in a build which would conflict.

    Did you try these? Particularly number 5. https://forum.unity.com/threads/troubleshooting-addressables-issues.1060346/

    The Bundle Layout Preview rule just shows you what asset bundles the assets will go into, it does not mean something is wrong. Putting it under Unfixable rules does seem to imply that something is wrong but its not.
     
    thedollargamestore likes this.
  3. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Thanks for the insanely fast response @karl_jones . I've marked all of the locale assets as addressable, and the localization settings asset is not marked as addressable but to no avail. Please advise:



     
  4. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Apologies, I didn't reply directly to your answer. To also add to the below answer that I posted, I did follow the 5 issues you listed under the addressable issues thread but no luck unfortunately
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Did you mark them manually? You need to let the localization system handle marking them or they wont be correct. We don't just mark them but also set up various labels that are required. If you run the Analyzers they should detect any issues with this. https://docs.unity3d.com/Packages/com.unity.localization@1.0/manual/Addressables.html

    Can you share the log file of the built player? http://docs.unity3d.com/Manual/LogFiles.html
     
    thedollargamestore likes this.
  6. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Hi Karl,

    I've unmarked the "Addressable" fields and ran the analyzer to mark them for me, but still no luck.

    Please find attached the player log (I trust this is the right one): %USERPROFILE%\AppData\LocalLow\CompanyName\ProductName\Player.log
     

    Attached Files:

  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Hmm cant see anything to help. Have you tried using the Locale selector that comes in the Localization package Samples? Does that one work? It may be that you need to wait for the initialization operation.
    Can you check the value returned by
     LocalizationSettings.AvailableLocales.GetLocale(locale);

    Is it null?
     
    thedollargamestore likes this.
  8. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    That actually helped me narrow it down a bit thanks. So basically in the editor it has a value based on the locale, but when I try printing it out in the build itself I get this error on the logs:

    Locales PreloadOperation has not been initialized, can not return the available locales.
    NullReferenceException: Object reference not set to an instance of an object
    at LanguageSelector.Update () [0x0003d] in <09178970fdf74b198a385ba5eb2f0ee7>:0

    Can you please provide some guidance as to how I can go about resolving this?
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Take a look at the samples. You need to wait for the initialization operation to finish before calling GetLocale
     
    thedollargamestore likes this.
  10. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Hi Karl,

    Thank you for your help thus far! Adding the following has resolved the issue:

    Code (CSharp):
    1. IEnumerator Start()
    2.     {
    3.         yield return LocalizationSettings.InitializationOperation;
    4.     }
    I am however still experiencing a minor issue on the Web Build. When I select a language and try load a string it gives me the following error:

    "WebGL does not support synchronous Addressable loading. Please do not use WaitForCompletion on the WebGL platform."

    I've tried to follow the solution you provided here: https://forum.unity.com/threads/wai...on-in-webgl-for-addressables-1-18-15.1152719/

    I marked all the tables to preload, but I can't figure out where to toggle the following you mentioned:

    "You will need to disable the wait for completion flag on the LocalizedStrings."
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Select the LocalizedStringEvent and expand the StringReference field. You should see a toggle for WaitForCompletion. It should be off. Do you have the callstack for the error? It can also come from calling one of the Asyncronous methods such as GetLocalizedString instead of GetLocalizedStringAsync
     
    thedollargamestore likes this.
  12. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Thank you for your guidance Karl. By toggling all the settings and replacing GetLocalizedString with the asynchronous call it fixed all of the issues.

    One last (hopefully minor) question I have is as to why Chinese / Arabic / Hindi characters don't render on WEB GL at all? Portugeuse / Spanish / French works like a charm and on the windows build I can see the Chinese characters.

    I'm assuming it has something to do with the fallback fonts. Would this display correctly on people who are running browsers that support the respective languages?
     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Are you using the default unity font? I believe it is different per platform. You should pick fonts for each language that you know have all the characters you need regardless of the platform.

    Google have some good ones https://fonts.google.com
     
    thedollargamestore likes this.
  14. thedollargamestore

    thedollargamestore

    Joined:
    Sep 9, 2020
    Posts:
    8
    Thanks Karl, I'll take a look. Much appreciated!

    Is there anything I need to do from my side to mark this thread as solved?
     
  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    No that's fine
     
    thedollargamestore likes this.