docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Property LocaleOverride

    LocaleOverride

    Provide a locale that can be used instead of SelectedLocale. A null value will revert to using SelectedLocale.

    Declaration
    public Locale LocaleOverride { get; set; }
    Property Value
    Type Description
    Locale
    Examples

    This example shows how the LocaleOverride can be used in order to provide an alternative to SelectedLocale.

    public class LocaleOverrideExample : MonoBehaviour
    {
        public LocalizedString myString = new LocalizedString("My Table", "My Entry");
        public LocaleIdentifier localeOverride = SystemLanguage.Spanish; // Override to always use Spanish
    
        IEnumerator Start()
        {
            // Wait for the Locales to load.
            yield return LocalizationSettings.InitializationOperation;
    
            // Set the LocalizedString to use the locale override instead of the selected locale.
            myString.LocaleOverride = LocalizationSettings.AvailableLocales.GetLocale(localeOverride);
        }
    
        void OnGUI()
        {
            GUILayout.Label(myString.GetLocalizedString());
        }
    }
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)