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
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
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(LocaleIdentifier)
Declaration
public static Locale CreateLocale(LocaleIdentifier identifier)
Parameters
Returns
CreateLocale(SystemLanguage)
Create a Locale using the system language enum value.
Declaration
public static Locale CreateLocale(SystemLanguage language)
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 .
|