Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Locale

Creates a locale with no culture code.
Read time 1 minuteLast updated 10 days ago

Definition

  • Type: Constructor
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule

Locale()

Creates a locale with no culture code.
public Locale()

Remarks

The parameterless constructor exists mainly for serialization. Because Locale.Code is read-only, prefer Locale to create a usable locale. You can still set Locale.FallbackCode and Locale.LocaleName after construction.
Create an empty locale and set its fallback.

Examples

using Unity.Localization;namespace Unity.Localization.Samples{ public class LocaleConstructorEmptyExample { public Locale Run() { var locale = new Locale(); locale.FallbackCode = "en"; return locale; } }}

Locale(string, string)

Creates a locale for a culture code, with an optional display name.
public Locale(string code, string localeName = null)

Parameters

code

The culture code, for example "en" or "fr-CA".

localeName

The display name to show for this locale, or null to derive one from the culture.

Remarks

The culture code determines the Locale.Identifier and the formatting culture reported by Locale.CultureInfo. When
localeName
is null, Locale.LocaleName falls back to the culture's native name, then to the code itself.
Create a locale for a culture code with an explicit display name.

Examples

using Unity.Localization;namespace Unity.Localization.Samples{ public class LocaleConstructorExample { public Locale Run() => new Locale("de", "Deutsch"); }}