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

Locale Constructor

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

Declaration

public Locale();

Description

Creates a locale with no culture code.

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

<para>Create an empty locale and set its fallback.</para>

using Unity.Localization;

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

Declaration

public Locale(string code, string localeName);

Parameters

Parameter Description
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.

Description

Creates a locale for a culture code, with an optional display name.

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.

<para>Create a locale for a culture code with an explicit display name.</para>

using Unity.Localization;

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