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.
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.
Additional resources: LocaleIdentifier, ResourceTable, SharedTableData
<para>Create a locale, then read its identifier, display name, and formatting culture.</para>
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 } } }
| Property | Description |
|---|---|
| Code | The culture code, for example "en" or "fr-CA". |
| CultureInfo | The formatting culture for this locale, or the invariant culture when the code is not a known culture. |
| Enabled | Whether the locale is active: a disabled locale is excluded from runtime selection and its tables are not shipped in a build. |
| FallbackCode | The culture code of the fallback locale, resolved through the settings, or null when there is no fallback. |
| Identifier | The identifier for this locale. |
| LocaleName | The display name, for example "English". When not set, falls back to the culture's native name, then the code. |
| Constructor | Description |
|---|---|
| Locale | Creates a locale with no culture code. |