Android and LocalizationSettings.SelectedLocale

Hello,

I would to know if the Localisation package work on Android (and iOS)?

When I try to use LocalizationSettings.SelectedLocale, I have this error on Android:

Here the code:

private void LocaleSelected(int index)
{
     LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
}

Best,
Alexis

Yes, it should work on all platforms.
That issue is caused when it can not determine a startup locale.

Does it work in the Editor?

1 Like

Oh!

I forgot this step…

The package work in Editor without building addressable, so I didn’t this step…

Thanks! :slight_smile:

1 Like

Hi, I build applications on IOS but the language has not changed according to the system language.

I use ‘Unity2019.3.0f6’ + ‘Localization0.6.0-preview’, I have run the ‘Default Build Script’ command of the ‘Addressables Groups’ window and added several localization languages correctly. The language can be changed automatically in the Unity editor.

Do I need additional settings for automatic language switching on IOS?

You want it to default to the system language on iOS?

This is how the System Selector works:

if (Application.systemLanguage != SystemLanguage.Unknown)
{
locale = availableLocales.GetLocale(Application.systemLanguage);
}

If that fails it then checks the CultureInfo

var cultureInfo = CultureInfo.CurrentUICulture;
locale = availableLocales.GetLocale(cultureInfo);

Check what the values of Application.systemLanguage and CultureInfo.CurrentUICulture are, do they match the languages you have available?

1 Like

It works, thank you. I use ‘CultureInfo.CurrentUICulture’ and get a match.

Why was it failing for you?
Did you need to write custom code to do the match? The system selector should be finding it.

I don‘t know. I think my settings should be correct, but the language will not change automatically on my IOS(13.3.1). I put ‘GetLocale (cultureInfo)’ in ‘Awake ()’ and it worked.

Do you know what the value of Application.systemLanguage was?
Was it the same as the CultureInfo? Maybe we need to swap the order around so it checks CultureInfo first.

I created an empty project for testing and added three languages (English, Simplified Chinese, and French). I did not use ‘availableLocales.GetLocale (cultureInfo)’ in Awake (). I switched the system language of IOS for testing. As a result, Simplified Chinese did not change automatically in the game, English and French changed automatically in the game.

1 Like

Thanks, thats really helpful. I’ll look into it, could be a bug.

1 Like

Hi,
0.6.1-preview is released now, this includes a change that should fix your issues. Please let me know if it does not.

1 Like

Hi!

I’m new on Unity and I saw some videos of how add assets to addressable, but I don’t know how add the location address to Android :frowning:

Thanks!

You want to add localized assets or just normal addressable assets?
Localized are done through the asset table. Have you looked at the docs or the webinar video?

My problem was that I forget to build the Addresseables to work in android, srry :frowning:

(For someone with this problem)

  • Window → Asset Manager ->Addresseables → Groups → Build → New build

But now I have a little blink when I load the texts
When my game starts I preload the locales with LocalizationSettings.InitializationOperationbut when the scene loads and any text should appear, it tooks a little milliseconds to load and it causes a blink

Sorry if you answer this question a lot of times… but I don’t find any working solution for me

Exists any method to wait for a whole load to avoid these behaviors?

P.D Happy new year!

2 Likes

Do you go straight into the scene or do you have a menu/loading scene?
The preloading needs time to complete as it’s asynchronous. A simple loading screen screen would work. Wait for the LocalisationSettings.InitializationOperation to finish

1 Like

Yes, I have a loading screen with this code

IEnumerator Start()
    {
        yield return LocalizationSettings.InitializationOperation;

        // Begin to load the Scene you specify
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("MainMenuScene");

        // Don't let the Scene activate until you allow it to
        asyncOperation.allowSceneActivation = false;

        // When the load is still in progress, output the Text and progress bar
        while (!asyncOperation.isDone)
        {
            // Output the current progress
            progressText.text = "Loading progress: " + (asyncOperation.progress * 100) + "%";

            // Check if the load has finished
            if (asyncOperation.progress >= 0.9f)
            {
                // Change the Text to show the Scene is ready
                asyncOperation.allowSceneActivation = true;
            }

            yield return null;
        }
    }

but when the new scene loads (MainMenuScene), all buttons appears without text and some milliseconds after the text appears

(I tried even with ‘yield return new WaitSeconds(10)’ to wait more time, but the same blink happend on buttons)

Can you share the project?
Does this happen in the Editor or just Android?

Only happen on Android, I don’t know if because the computere is faster and I can’t see this blink or because on editor does not happend.

And the project… I’m not the only owner and the project have any private resources.
But if you don’t know what could be the problem without the code don’t worry, you helped a lot without all data :wink:

It really is my problem jajaja If finally I find any solution, I will post here to share it with all of you, maybe someone have the same problem

P.D: If this help you to improve the code, I know that the location project is still in preview, but for newe people is a little dificcult to start using it, at least in my case

Does the problem happen in a new project? If it does then feel free to file a bug report so we can look into it.