Class Locale
A Locale represents a language. It supports regional variations and can be configured with an optional fallback Locale via metadata.
Syntax
public class Locale : ScriptableObject, IEquatable<Locale>, IComparable<Locale>, ISerializationCallbackReceiver
Properties
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
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
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
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
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
Declaration
public bool UseCustomFormatter { get; set; }
Property Value
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
CreateLocale(CultureInfo)
Create a Locale using a CultureInfo.
Declaration
public static Locale CreateLocale(CultureInfo cultureInfo)
Parameters
Type |
Name |
Description |
CultureInfo |
cultureInfo |
|
Returns
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
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
CreateLocale(LocaleIdentifier)
Declaration
public static Locale CreateLocale(LocaleIdentifier identifier)
Parameters
Returns
Equals(Locale)
Declaration
public bool Equals(Locale other)
Parameters
Type |
Name |
Description |
Locale |
other |
|
Returns
GetFallback()
Returns the fallback locale or null
if one does not exist or it could not be found.
Declaration
public virtual Locale GetFallback()
Returns
Type |
Description |
Locale |
The fallback locale or null .
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
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.