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

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:

LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(locale);

//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.

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. Troubleshooting Addressables Issues

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.

1 Like

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:

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

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

1 Like

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

7591120–941311–Player.zip (928 Bytes)

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?

1 Like

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?

Take a look at the samples. You need to wait for the initialization operation to finish before calling GetLocale

1 Like

Hi Karl,

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

IEnumerator Start()
    {
        yield return LocalizationSettings.InitializationOperation;
    }

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://discussions.unity.com/t/851237

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.”

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

1 Like

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?

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

1 Like

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?

No that’s fine

1 Like