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

Locale

class 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

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

Properties

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.

Constructors

Constructor Description
Locale Creates a locale with no culture code.