GetLocale(LocaleIdentifier)
Returns the available locale with the given identifier, or null.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public Locale GetLocale(LocaleIdentifier identifier)
Parameters
The identifier of the locale to find.
Returns
Type | Description |
|---|---|
| Locale | The registered locale that matches the identifier, or null when none matches. |
Remarks
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.
Finds a locale by code and selects it.
Examples
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; } }}