Unity localization locale stuck

Selected locale stuck on on language.
I am implementing localization with the Unity package. Now I set up 3 languages, english, dutch and german. The problem however is that every time i play the game (in editor). It defaults to Dutch, while i selected English as the standard language.

A bigger problem is that when I tried to make buttons for language selection they dont seem to change the language at all, nothing changes. All the string tables, string event is setup properly since if iuse the dropdown menu in game view to change the language it does work.

Anyone any idea what I am doing wrong?


English is setup as default language.

Script for buttons:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization.Settings;

/// <summary>
/// Handles changing the game's locale dynamically.
/// </summary>
public class LocaleSelector : MonoBehaviour
{
    private bool active = false;

    /// <summary>
    /// Changes the current locale based on the provided locale ID.
    /// </summary>
    /// <param name="localeID">The index of the locale in the Available Locales list.</param>
    public void ChangeLocale(int localeID)
    {
        if (active == true)
            return;
        StartCoroutine(SetLocale(localeID));
    }

    /// <summary>
    /// Coroutine that sets the locale after ensuring the Localization system is initialized.
    /// </summary>
    /// <param name="localeID">The index of the locale in the Available Locales list.</param>
    private IEnumerator SetLocale(int localeID)
    {
        active = true;
        yield return LocalizationSettings.InitializationOperation;
        LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[localeID];
        active = false;
    }
}

Hi,

The startup language is chosen by the Locale selectors. It starts with the item at the top and works down until it finds a match. In your screenshot you have the Command Line Locale Selector and the System Locale Selector above the Specific Locale Selector (English). The System Locale Selector is likely selecting Dutch. If you want to force English you can move the Specific one to the top of the list, maybe even remove the other 2.

You script doesnt seem to do anything. I dont see what calls ChangeLocale, is this linked to a button callback? Try taking a look at the package samples, we have a few language selection examples.

Thanks, putting the specefic one on top indeed worked. Checked out the samples and got it working now thanks for the help!

1 Like