e34897cd1f
## Summary of the Pull Request This PR adds a global "language" setting, which may be set to any supported BCP 47 tag. Additionally a ComboBox is added to the settings UI under "Appearance", listing all languages with their localized names. This PR introduces one new issue: If you change the language while the app is running, the UI will be in a torn state, as not all UI elements refresh automatically if the `PrimaryLanguageOverride` is changed. ## PR Checklist * [x] Closes #5497 * [x] I work here * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated ## Validation Steps Performed * UI language changes when changing the "language" in settings.json before starting WT / while WT is running. ✔️ * "language" field is removed from settings.json if "Use system default" is selected. ✔️ * "language" field is added or updated in settings.json if any other language is selected. ✔️ * Removes qps- languages if debugFeatures is false. ✔️ * Correctly refreshes all UI elements with the new language. ❌
54 lines
2.1 KiB
C++
54 lines
2.1 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "GlobalAppearance.g.h"
|
|
#include "GlobalAppearancePageNavigationState.g.h"
|
|
#include "Utils.h"
|
|
|
|
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
{
|
|
struct GlobalAppearancePageNavigationState : GlobalAppearancePageNavigationStateT<GlobalAppearancePageNavigationState>
|
|
{
|
|
public:
|
|
GlobalAppearancePageNavigationState(const Model::GlobalAppSettings& settings) :
|
|
_Globals{ settings } {}
|
|
|
|
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
|
};
|
|
|
|
struct GlobalAppearance : GlobalAppearanceT<GlobalAppearance>
|
|
{
|
|
public:
|
|
GlobalAppearance();
|
|
|
|
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
|
|
|
|
WINRT_PROPERTY(Editor::GlobalAppearancePageNavigationState, State, nullptr);
|
|
GETSET_BINDABLE_ENUM_SETTING(Theme, winrt::Windows::UI::Xaml::ElementTheme, State().Globals, Theme);
|
|
GETSET_BINDABLE_ENUM_SETTING(TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, State().Globals, TabWidthMode);
|
|
|
|
public:
|
|
// LanguageDisplayConverter maps the given BCP 47 tag to a localized string.
|
|
// For instance "en-US" produces "English (United States)", while "de-DE" produces
|
|
// "Deutsch (Deutschland)". This works independently of the user's locale.
|
|
static winrt::hstring LanguageDisplayConverter(const winrt::hstring& tag);
|
|
|
|
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> LanguageList();
|
|
winrt::Windows::Foundation::IInspectable CurrentLanguage();
|
|
void CurrentLanguage(const winrt::Windows::Foundation::IInspectable& tag);
|
|
|
|
private:
|
|
std::vector<winrt::hstring> _GetSupportedLanguageTags();
|
|
|
|
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> _languageList{ nullptr };
|
|
winrt::hstring _currentLanguage;
|
|
};
|
|
}
|
|
|
|
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
{
|
|
BASIC_FACTORY(GlobalAppearance);
|
|
}
|