Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

LocaleIdentifier

struct in Unity.Localization

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Identifies a locale by its culture code, for example "en" or "fr-CA".

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

<para>Create an identifier from a code, then compare it against another case-insensitively.</para>

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) } } }

Properties

Property Description
Code The culture code, or the empty string when the identifier is undefined.

Constructors

Constructor Description
LocaleIdentifier Creates an identifier from a culture code.

Public Methods

Method Description
Equals Checks whether this identifier has the same culture code as another.
GetHashCode Computes a hash code for this identifier.
ToString Returns the culture code for this identifier.

Operators

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