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

LocalizationSettings.GetLocale

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 GetLocale(LocaleIdentifier identifier);

Parameters

Parameter Description
identifier The identifier of the locale to find.

Returns

Locale The registered locale that matches the identifier, or null when none matches.

Description

Returns the available locale with the given identifier, or null.

Searches LocalizationSettings.AvailableLocales for a locale whose LocaleIdentifier matches, including disabled locales. The match is case-insensitive on the locale code. Use this to turn a code into a Locale before assigning it to LocalizationSettings.SelectedLocale.

<para>Finds a locale by code and selects it.</para>

using Unity.Localization;

namespace Unity.Localization.Samples { public class GetLocaleExample { public void Run() { Locale french = LocalizationSettings.Instance.GetLocale(new LocaleIdentifier("fr")); if (french != null) LocalizationSettings.SelectedLocale = french; } } }