Hi, I’m trying to change via script the selected Locale by pressing a button.
Is there a specific way to do this?
By searching on internet I found following solution but it doesn’t work:
LocalizationSettings.SelectedLocale.Identifier = languageIdentifier;
I’ve tried also to change directly the SelectedLocale but nothing…
LocalizationSettings.SelectedLocale = newLocale;
Can you help me please? Thank you 
We have some samples in the package that show how to create a language selection menu. Open the package manager and look at the samples in the localization package info screen.
https://docs.unity3d.com/Packages/com.unity.localization@1.3/manual/Package-Samples.html
There is also an example here Scripting | Localization | 1.3.2
1 Like
Hi, thank you so much for the answer, as always :).
I don’t know why, Unity was “stuck” and, restarting it, it started to work right again.
The following code represents my simple solution and it works great for my purpose.
public void SetNewLocale()
{
switch (language)
{
case "en":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[0];
break;
case "fr":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[1];
break;
case "it":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[2];
break;
case "es":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[3];
break;
default:
break;
}
}
2 Likes
Depending on the realization of your code, you could also utilize the following code :
public void OnNextLocaleShowed()
{
_localeIndex = _localeIndex + 1 >= LocalizationSettings.AvailableLocales.Locales.Count ? 0 : _localeIndex + 1;
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[_localeIndex];
}
In my realization of the localization system, when a player presses a button, it switches to the next language from the list of locales