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

SystemLocaleSelector

class in Unity.Localization


Implements interfaces:IStartupLocaleSelector

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

Description

Detects the locale from the device's current UI culture and matches the closest available locale.

This selector reads the system UI culture (Globalization.CultureInfo.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, SystemLocaleSelector.GetStartupLocale returns null. This selector is part of the default selector chain. Override SystemLocaleSelector.GetSystemCulture to supply a fixed culture in tests.

Additional resources: IStartupLocaleSelector, LocalizationSettings

<para>Selects the locale that best matches the device language.</para>

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; } } }

Protected Methods

Method Description
GetSystemCulture Returns the system culture used to detect the startup locale.