Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

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
fr-FR
but only
fr
is available, it selects
fr
. 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.
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

GetSystemCultureReturns the system culture used to detect the startup locale.