# SystemLocaleSelector

> Detects the language the device is set to and matches the closest available locale.

## Definition

* **Type:** Class
* **Namespace:** [Unity.Localization](/engine/6000.7/script-reference/unity/localization.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule
* **Implements:** [IStartupLocaleSelector](/engine/6000.7/script-reference/unity/localization/istartuplocaleselector.md)

```csharp
public class SystemLocaleSelector : IStartupLocaleSelector
```

## Remarks

This selector first tries [SystemLocaleSelector.GetSystemCulture](/engine/6000.7/script-reference/unity/localization/systemlocaleselector/getsystemculture.md), which reports the language the user asked the operating system for. Apple platforms, Android and WebGL give that as a language tag carrying the region and the script, such as `pt-BR` or `zh-Hant-TW`; elsewhere it falls back to CurrentUICulture. When no locale matches it tries [\_systemLanguage](/engine/6000.7/script-reference/unityengine/application/systemlanguage.md), which every platform reports but which carries the language alone. Each answer is matched against [LocaleIdentifier](/engine/6000.7/script-reference/unity/localization/localeidentifier.md) and then up the culture parent chain, so a device set to `fr-FR` selects `fr` when only `fr` is available. Disabled locales are passed over, so a disabled match does not stop the search. If nothing matches, GetStartupLocale returns null and the next selector in [LocalizationSettings.StartupSelectors](/engine/6000.7/script-reference/unity/localization/localizationsettings/startupselectors.md) runs. This selector is part of the default selector chain. Override [SystemLocaleSelector.GetSystemCulture](/engine/6000.7/script-reference/unity/localization/systemlocaleselector/getsystemculture.md) to supply a fixed culture in tests.

Additional Resources: [IStartupLocaleSelector](/engine/6000.7/script-reference/unity/localization/istartuplocaleselector.md), [LocalizationSettings](/engine/6000.7/script-reference/unity/localization/localizationsettings.md)

Selects the locale that best matches the device language.

## Examples

```csharp
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](/engine/6000.7/script-reference/unity/localization/systemlocaleselector/getsystemculture.md) | Returns the culture used to detect the startup locale. |
