Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp (C++)

Code before:
    GlobalAppearance::GlobalAppearance()
    {
        InitializeComponent();

        INITIALIZE_BINDABLE_ENUM_SETTING(Theme, ElementTheme, winrt::Windows::UI::Xaml::ElementTheme, L"Globals_Theme", L"Content");
        INITIALIZE_BINDABLE_ENUM_SETTING(TabWidthMode, TabViewWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, L"Globals_TabWidthMode", L"Content");
    }

    void GlobalAppearance::OnNavigatedTo(const NavigationEventArgs& e)
    {
        _State = e.Parameter().as<Editor::GlobalAppearancePageNavigationState>();
    }

    winrt::hstring GlobalAppearance::LanguageDisplayConverter(const winrt::hstring& tag)
    {
        if (tag == systemLanguageTag)
        {
            return RS_(L"Globals_Language_Default");
        }

        winrt::Windows::Globalization::Language language(tag);
        return language.NativeName();
    }

    // Returns an array of {"und", "en-US", "de-DE", "es-ES", ...}.
    // "und" is short for "undefined" and is synonym for "Use system language" in this code.
    winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> GlobalAppearance::LanguageList()
    {
        // The following code achieves the following:
        // [1] Get all possible languages we want to allow the user to choose
        // [2] Sort languages by their ASCII tags, forcing the UI in a consistent/stable order
        //     I wanted to sort the localized language names initially, but it turned out to be complex.
        // [3] Remove duplicates between the array of tagSources from 1.
        //     We don't want to have en-US twice in the list, do we?
        // [4] Optionally remove unwanted language tags.

        std::vector<winrt::hstring> tags;

        // [1]:
        {
            // ManifestLanguages contains languages the app ships with.
            //
            // Languages is a computed list that merges the ManifestLanguages with the
            // user's ranked list of preferred languages taken from the system settings.
            // As is tradition the API documentation is incomplete though, as it can also
            // contain regional language variants. If our app supports en-US, but the user
            // has en-GB or en-DE in their system's preferred language list, Languages will
            // contain those as well, as they're variants from a supported language. We should
            // allow a user to select those, as regional formattings can vary significantly.
            const std::array tagSources{
                winrt::Windows::Globalization::ApplicationLanguages::ManifestLanguages(),

Review comment (suggestion):
```suggestion
    // "und" is short for "undefined" and is synonymous for "Use system language" in this code.
```

Code after:
        _State = e.Parameter().as<Editor::GlobalAppearancePageNavigationState>();
    }

    winrt::hstring GlobalAppearance::LanguageDisplayConverter(const winrt::hstring& tag)
    {
        if (tag == systemLanguageTag)
        {
            return RS_(L"Globals_LanguageDefault");
        }

        winrt::Windows::Globalization::Language language{ tag };
        return language.NativeName();
    }

    // Returns the list of languages the user may override the application language with.
    // The returned list are BCP 47 language tags like {"und", "en-US", "de-DE", "es-ES", ...}.
    // "und" is short for "undefined" and is synonymous for "Use system language" in this code.
    winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> GlobalAppearance::LanguageList()
    {
        if (_languageList)
        {
            return _languageList;
        }

        // In order to return the language list this code does the following:
        // [1] Get all possible languages we want to allow the user to choose.
        //     We have to acquire languages from multiple sources, creating duplicates. See below at [1].
        // [2] Sort languages by their ASCII tags, forcing the UI in a consistent/stable order.
        //     I wanted to sort the localized language names initially, but it turned out to be complex.
        // [3] Remove potential duplicates in our language list from [1].
        //     We don't want to have en-US twice in the list, do we?
        // [4] Optionally remove unwanted language tags (like pseudo-localizations).

        std::vector<winrt::hstring> tags;

        // [1]:
        {
            // ManifestLanguages contains languages the app ships with.
            //
            // Languages is a computed list that merges the ManifestLanguages with the
            // user's ranked list of preferred languages taken from the system settings.
            // As is tradition the API documentation is incomplete though, as it can also
            // contain regional language variants. If our app supports en-US, but the user
            // has en-GB or en-DE in their system's preferred language list, Languages will
            // contain those as well, as they're variants from a supported language. We should
            // allow a user to select those, as regional formattings can vary significantly.
            const std::array tagSources{
                winrt::Windows::Globalization::ApplicationLanguages::ManifestLanguages(),
                winrt::Windows::Globalization::ApplicationLanguages::Languages()
            };