LocaleIdentifier
Identifies a locale by its culture code, for example "en" or "fr-CA".
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Struct
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IEquatable<LocaleIdentifier>
public struct LocaleIdentifier : IEquatable<LocaleIdentifier>
Remarks
This is the minimal identifier used to scope cached assets per locale. The full locale model (display name, fallbacks, formatting culture) lives on Locale. Two identifiers compare equal when their codes match, ignoring case. The default value is the undefined locale, whose LocaleIdentifier.Code is the empty string.
Create an identifier from a code, then compare it against another case-insensitively.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class LocaleIdentifierOverviewExample { public void Run() { LocaleIdentifier identifier = "en"; // implicit conversion from string Debug.Log(identifier.Code); // en Debug.Log(identifier == new LocaleIdentifier("EN")); // True (case-insensitive) } }}
Constructors
Constructor | Description |
|---|---|
| LocaleIdentifier(System.String) | Creates an identifier from a culture code. |
Properties
Property | Description |
|---|---|
| Code | The culture code, or the empty string when the identifier is undefined. |
Methods
Method | Description |
|---|---|
| Equals | Checks whether this identifier equals another object. |
| GetHashCode | Computes a hash code for this identifier. |
| ToString | Returns the culture code for this identifier. |
Operators
Operator | Description |
|---|---|
| operator == | Determines whether two identifiers have the same culture code. |
| LocaleIdentifier | Converts a culture code string into an identifier. |
| operator != | Determines whether two identifiers have different culture codes. |