Raised after the selected locale changes.
Subscribe to this static event to update UI or reload content when the user switches language. It is invoked
after LocalizationSettings.SelectedLocale has changed, both during startup selection and on later changes; the new
locale is passed to the handler. Because it is static, unsubscribe when your object is destroyed to avoid
leaks. To run code once when initialization finishes instead, use LocalizationSettings.InitializationCompleted.
Additional resources: LocalizationSettings.SelectedLocale, LocalizationSettings.InitializationCompleted
<para>Refreshes a label whenever the locale changes.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class SelectedLocaleChangedExample : MonoBehaviour { void OnEnable() => LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged; void OnDisable() => LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged;
void OnLocaleChanged(Locale locale) => Debug.Log($"Locale is now {locale?.Code}"); } }