Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LocaleIdentifier

Identifies a locale by its culture code, for example "en" or "fr-CA".
Read time 1 minuteLast updated 12 days ago

Definition

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.
Additional Resources: Locale, ResourceTable, SharedTableData
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

CodeThe culture code, or the empty string when the identifier is undefined.

Methods

Method

Description

EqualsChecks whether this identifier equals another object.
GetHashCodeComputes a hash code for this identifier.
ToStringReturns the culture code for this identifier.

Operators

Operator

Description

operator ==Determines whether two identifiers have the same culture code.
LocaleIdentifierConverts a culture code string into an identifier.
operator !=Determines whether two identifiers have different culture codes.