docs.unity3d.com
    Show / Hide Table of Contents

    Class Locale

    A Locale represents a language. It supports regional variations and can be configured with an optional fallback Locale via metadata.

    Inheritance
    Object
    Object
    ScriptableObject
    Locale
    PseudoLocale
    Inherited Members
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(String)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.Localization
    Syntax
    public class Locale : ScriptableObject, IEquatable<Locale>, IComparable<Locale>, ISerializationCallbackReceiver

    Properties

    CustomFormatterCode

    The Language code to use when applying any culture specific string formatting, such as date, time, currency. By default, the Identifier Code will be used however this field can be used to override this such as when you are using a custom Locale which has no known formatter.

    Declaration
    public string CustomFormatterCode { get; set; }
    Property Value
    Type Description
    String

    Formatter

    The Formatter that will be applied to any Smart Strings for this Locale. By default, the Identifier CultureInfo will be used when CustomFormatterCode is not set.

    Declaration
    public virtual IFormatProvider Formatter { get; set; }
    Property Value
    Type Description
    IFormatProvider

    Identifier

    The identifier contains the identifying information such as the id and culture Code for this Locale.

    Declaration
    public LocaleIdentifier Identifier { get; set; }
    Property Value
    Type Description
    LocaleIdentifier

    LocaleName

    The name of the Locale. This can be used to customize how the Locale name should be presented to the user, such as in a language selection menu.

    Declaration
    public string LocaleName { get; set; }
    Property Value
    Type Description
    String

    Metadata

    Optional Metadata. It is possible to attach additional data to the Locale providing it implements the IMetadata interface and is serializable.

    Declaration
    public MetadataCollection Metadata { get; set; }
    Property Value
    Type Description
    MetadataCollection

    SortOrder

    The sort order can be used to override the order of Locales when sorted in a list. If Locales both have the same SortOrder then they will be sorted by name.

    Declaration
    public ushort SortOrder { get; set; }
    Property Value
    Type Description
    UInt16

    UseCustomFormatter

    When true, CustomFormatterCode will be used for any culture sensitive formatting instead of Identifier.

    Declaration
    public bool UseCustomFormatter { get; set; }
    Property Value
    Type Description
    Boolean

    Methods

    CompareTo(Locale)

    Compares the Locales properties. First the sort orders are compared, if they are the same then the LocaleName will be considered instead.

    Declaration
    public int CompareTo(Locale other)
    Parameters
    Type Name Description
    Locale other
    Returns
    Type Description
    Int32

    CreateLocale(CultureInfo)

    Create a Locale using a CultureInfo.

    Declaration
    public static Locale CreateLocale(CultureInfo cultureInfo)
    Parameters
    Type Name Description
    CultureInfo cultureInfo
    Returns
    Type Description
    Locale

    CreateLocale(String)

    Create a new Locale using the culture code.

    Declaration
    public static Locale CreateLocale(string code)
    Parameters
    Type Name Description
    String code

    Culture code.

    Returns
    Type Description
    Locale

    CreateLocale(LocaleIdentifier)

    Create a new Locale using the provided LocaleIdentifier.

    Declaration
    public static Locale CreateLocale(LocaleIdentifier identifier)
    Parameters
    Type Name Description
    LocaleIdentifier identifier
    Returns
    Type Description
    Locale

    CreateLocale(SystemLanguage)

    Create a Locale using the system language enum value.

    Declaration
    public static Locale CreateLocale(SystemLanguage language)
    Parameters
    Type Name Description
    SystemLanguage language
    Returns
    Type Description
    Locale

    Equals(Locale)

    Compares the Locale Identifier properties.

    Declaration
    public bool Equals(Locale other)
    Parameters
    Type Name Description
    Locale other
    Returns
    Type Description
    Boolean

    GetFallback()

    Returns the first fallback locale or null if one does not exist or it could not be found.

    Declaration
    [Obsolete("GetFallback is obsolete, please use GetFallbacks.")]
    public virtual Locale GetFallback()
    Returns
    Type Description
    Locale

    The fallback locale or null.

    GetFallbacks()

    Returns the fallbacks in order or priority. If the locale does not contain any FallbackLocale metadata then the CultureInfo will be used to find a fallback.

    Declaration
    public IEnumerable<Locale> GetFallbacks()
    Returns
    Type Description
    IEnumerable<Locale>

    The fallback locale or null.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • CustomFormatterCode
      • Formatter
      • Identifier
      • LocaleName
      • Metadata
      • SortOrder
      • UseCustomFormatter
    • Methods
      • CompareTo(Locale)
      • CreateLocale(CultureInfo)
      • CreateLocale(String)
      • CreateLocale(LocaleIdentifier)
      • CreateLocale(SystemLanguage)
      • Equals(Locale)
      • GetFallback()
      • GetFallbacks()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023