Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Locale

Represents a selectable language or region in a localized project. A locale carries a culture code, an optional display name, a formatting culture, and an optional fallback.
Read time 2 minutesLast updated 6 days ago

Definition

  • Type: Class
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public class Locale

Remarks

A locale is the unit the runtime selects between when it resolves localized content. It pairs a LocaleIdentifier (the culture code) with a display name and the formatting culture reported by Locale.CultureInfo, which drives number, date, and string formatting. When a value is missing in the selected locale, the runtime can fall back to the locale named by Locale.FallbackCode. A locale is a plain serializable object rather than a
ScriptableObject
asset, so it is stored inline in the localization settings.
Create a locale, then read its identifier, display name, and formatting culture.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class LocaleOverviewExample { public void Run() { var locale = new Locale("fr-CA", "French (Canada)"); Debug.Log(locale.Identifier); // fr-CA Debug.Log(locale.LocaleName); // French (Canada) Debug.Log(locale.CultureInfo.Name); // fr-CA Debug.Log(locale.Enabled); // True } }}

Constructors

Constructor

Description

Locale()Creates a locale with no culture code.
Locale(System.String,System.String)Creates a locale for a culture code, with an optional display name.

Properties

Property

Description

CodeThe culture code, for example "en" or "fr-CA".
CultureInfoThe formatting culture for this locale, or the invariant culture when the code is not a known culture.
EnabledWhether the locale is active: a disabled locale is excluded from runtime selection and its tables are not shipped in a build.
FallbackCodeThe culture code of the fallback locale, resolved through the settings, or null when there is no fallback.
IdentifierThe identifier for this locale.
LocaleNameThe display name, for example "English". When not set, falls back to the culture's native name, then the code.