# Create a language selection menu

> Add a language selection menu to a UI Toolkit interface.

Add a language selection menu to a UI Toolkit interface.

This example builds a settings menu where the user picks the language. The two built-in controls don't need any setup code. They list the enabled locales, follow language changes from anywhere else in the application, and apply the user's choice to the whole application.

## Prerequisites

Before you start, make sure you have the following:

* Localization settings with two or more locales. Refer to [Get started with localization](/engine/6000.7/manual/get-started.md).
* A runtime UI document. Refer to [Get started with runtime UI](/engine/6000.7/manual/uitoolkits/uielements/uie-support-for-runtime-ui/uie-get-started-with-runtime-ui.md).

## Add the controls

In UI Builder, the controls appear in the library under **Controls**: **Language Dropdown** ([`LanguageDropdown`](/engine/6000.7/script-reference/unity/localization/ui/languagedropdown.md)) and **Language Radio Button Group** ([`LanguageRadioButtonGroup`](/engine/6000.7/script-reference/unity/localization/ui/languageradiobuttongroup.md)). Click and drag the control that fits your menu into the **Hierarchy** pane, or author it in UI Toolkit XML (UXML):

```xml
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:loc="Unity.Localization.UI">
    <ui:VisualElement name="language-settings" style="width: 300px;">
        <loc:LanguageDropdown label="Language" />
        <loc:LanguageRadioButtonGroup name="language-choices" />
    </ui:VisualElement>
</ui:UXML>

```

When the user selects a language in either control, the control sets [`LocalizationSettings.SelectedLocale`](/engine/6000.7/script-reference/unity/localization/localizationsettings/selectedlocale.md), and every localized string, asset, and binding updates. Locales discovered from data files appear in the controls when localization finishes initializing.

## React to the change

The controls don't need any setup code. To let other systems follow the user's choice, subscribe to [`SelectedLocaleChanged`](/engine/6000.7/script-reference/unity/localization/localizationsettings/selectedlocalechanged.md):

```cs
public class LanguageSelectionMenu : MonoBehaviour
    {
        // The language controls in the UXML need no setup code: they fill themselves from the
        // available locales and write the player's choice to LocalizationSettings.SelectedLocale.
        void OnEnable() => LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged;

        void OnDisable() => LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged;

        void OnLocaleChanged(Locale locale)
        {
            Debug.Log($"Language changed to {locale.LocaleName}");
        }
    }
```

## Persist the choice

To reopen the application in the chosen language, add the **Player Pref Locale Selector** to the startup selectors list in the Localization settings, before the **System Locale Selector**. The Player Pref Locale Selector saves every change and restores the saved locale at startup. To store the choice somewhere else, for example a save file, refer to [Create a custom startup locale selector](/engine/6000.7/manual/localization/examples/example-custom-startup-locale-selector.md).

## Additional resources

* [Localize UI created with UI Toolkit](/engine/6000.7/manual/localization/translations/localize-ui-toolkit.md)
* [Create a custom startup locale selector](/engine/6000.7/manual/localization/examples/example-custom-startup-locale-selector.md)
* [Locales](/engine/6000.7/manual/localization/locales.md)
