-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a language switcher using PrimaryLanguageOverride #10309
Conversation
48a2cd9
to
8e7b994
Compare
8e7b994
to
d92f4ca
Compare
d92f4ca
to
249f152
Compare
@@ -25,40 +25,39 @@ | |||
|
|||
#include <wil/cppwinrt.h> | |||
|
|||
#include <unknwn.h> | |||
|
|||
#include <hstring.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I had to add <winrt/Windows.Globalization.h>
to some pch.h files I decided to cleaned them up by removing unused includes and ordering and reordered the includes alphabetically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be careful! you must include unknwn and hstring BEFORE any c++/winrt headers; wil
is also sensitive to include order (!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed those entirely, because it compiles without them.
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
<!-- Theme --> | ||
<local:SettingContainer x:Uid="Globals_Theme" | ||
<!-- Language --> | ||
<local:SettingContainer x:Uid="Globals_Language" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure where I should put the ComboBox. Would it look better elsewhere? Maybe not as the first item in the Appearances section?
The reason I put it as the first item was simply because I thought it looked nicer that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now. Ideally, this would go into some kind of "General" page, but we're just not there yet imo.
@cinnamon-msft thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits.
Concerned about the torn state where some stuff stays localized and other stuff doesn't update.
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: follow the format we use for method descriptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I had hoped we only use that format for existing code/files...
It's rather verbose and sometimes redundant. (I'll change this comment.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've extended the comment, better detailing what it does...
If you don't mind I'll wait for others to concur with you until I change the style to what I perceive as the more verbose form.
regarding the resw file: please re-save it using visual studio to "repair" the spacing 😄 |
@DHowett @carlos-zamora If I change something in the .resw file and re-save it the spaces continue to be gone. |
I am surprised about that. I guess we can just commit it; the next person to change it using VS will reintroduce them. 😄 |
Oooooh... Nevermind... Apparently VS Code suppresses whitespace differences by default in the diff viewer! |
This comment has been minimized.
This comment has been minimized.
X |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find fault with this. Very well done!
@@ -5,6 +5,10 @@ | |||
#include "GlobalAppearance.h" | |||
#include "GlobalAppearance.g.cpp" | |||
#include "GlobalAppearancePageNavigationState.g.cpp" | |||
|
|||
#include <LibraryResources.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the precompiled header precomp.h or pch.h and not be necessary here
<numeric>
should be in LibraryIncludes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure putting it into <LibraryIncludes>
or the pch.h
file is a good idea?
<numeric>
is basically only used in 2 places throughout the project.
Now, what happens if:
|
@DHowett This PR """abuses""" the fact that the SUI saves the settings.json and triggers a settings reload in AppLogic. Then in AppLogic I compare the "language" settings value with the one returned by |
Indeed. I'm just hoping that it doesn't crash or overwrite the setting or do something weird if the JSON value doesn't exist in the actual language Combo list. |
if (!_State.Globals().DebugFeaturesEnabled()) | ||
{ | ||
// [4] part 1: | ||
it = std::remove_if(it, tagsEnd, [](const winrt::hstring& tag) mutable -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DHowett FYI I just realized this is a programming error and should be std::remove_if(tagsBegin, it, ...)
instead. std::unique
returns an iterator for the new end of the range, which I have to use instead of tagsEnd
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just create a follow-up task for...
- Settings UI not being reloaded entirely
- offline discussion: looks like you need to reload all of the NavigationView's menu items and also reload the page footer (with the save button)
- Command Palette sometimes not reloading (nested?) commands
Hello @lhecker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
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
Validation Steps Performed