SystemLocaleSelector
Detects the locale from the device's current UI culture and matches the closest available locale.
Read time 1 minuteLast updated 9 days ago
Definition
- Type: Class
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IStartupLocaleSelector
public class SystemLocaleSelector : IStartupLocaleSelector
Remarks
This selector reads the system UI culture (CurrentUICulture) and walks up the culture parent chain, returning the first available locale whose LocaleIdentifier matches. For example, if the device culture is but only is available, it selects . If no ancestor culture matches, GetStartupLocale returns null. This selector is part of the default selector chain. Override SystemLocaleSelector.GetSystemCulture to supply a fixed culture in tests.
fr-FRfrfrAdditional Resources: IStartupLocaleSelector, LocalizationSettings
Selects the locale that best matches the device language.
Examples
using Unity.Localization;namespace Unity.Localization.Samples{ public class SystemLocaleSelectorExample { public Locale Run() { var selector = new SystemLocaleSelector(); Locale locale = selector.GetStartupLocale(LocalizationSettings.Instance); return locale; } }}
Methods
Method | Description |
|---|---|
| GetSystemCulture | Returns the system culture used to detect the startup locale. |