Skip to content

Commit

Permalink
Add settings UI string localization (#7833)
Browse files Browse the repository at this point in the history
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
Moved all strings into resources file for localization.

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? -->

<!-- Please review the items on the PR checklist before submitting-->
* [ ] Closes #xxx
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] 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
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
  • Loading branch information
cinnamon-msft authored and carlos-zamora committed Oct 14, 2020
1 parent 9493ca0 commit 8b402c5
Show file tree
Hide file tree
Showing 10 changed files with 940 additions and 165 deletions.
128 changes: 128 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,6 +2519,134 @@ namespace winrt::TerminalApp::implementation
return _isAlwaysOnTop;
}

// Method Description:
// - Updates all tabs with their current index in _tabs.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::_UpdateTabIndices()
{
for (uint32_t i = 0; i < _tabs.Size(); ++i)
{
auto command = _tabs.GetAt(i).SwitchToTabCommand();
command.Action().Args().as<SwitchToTabArgs>().TabIndex(i);
}
}

// Method Description:
// - Creates a settings UI tab and focuses it. If there's already a settings UI tab open,
// just focus the existing one.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::_OpenSettingsUI()
{
// If we're holding the settings tab's switch command, don't create a new one, switch to the existing one.
if (!_switchToSettingsCommand)
{
auto newTabImpl = winrt::make_self<SettingsTab>();
_MakeSwitchToTabCommand(*newTabImpl, _tabs.Size());

// Add the new tab to the list of our tabs.
_tabs.Append(*newTabImpl);

// Don't capture a strong ref to the tab. If the tab is removed as this
// is called, we don't really care anymore about handling the event.
auto weakTab = make_weak(newTabImpl);

auto tabViewItem = newTabImpl->TabViewItem();
_tabView.TabItems().Append(tabViewItem);

_ReapplyCompactTabSize();

tabViewItem.PointerPressed({ this, &TerminalPage::_OnTabClick });

// When the tab is closed, remove it from our list of tabs.
newTabImpl->Closed([tabViewItem, weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
if (auto page{ weakThis.get() })
{
page->_switchToSettingsCommand = nullptr;
page->_RemoveOnCloseRoutine(tabViewItem, page);
}
});

_switchToSettingsCommand = newTabImpl->SwitchToTabCommand();

// This kicks off TabView::SelectionChanged, in response to which
// we'll attach the terminal's Xaml control to the Xaml root.
_tabView.SelectedItem(tabViewItem);
}
else
{
_actionDispatch->DoAction(_switchToSettingsCommand.Action());
}
}

// Method Description:
// - Returns a com_ptr to the implementation type of the given tab if it's a TerminalTab.
// If the tab is not a TerminalTab, returns nullptr.
// Arguments:
// - tab: the projected type of a Tab
// Return Value:
// - If the tab is a TerminalTab, a com_ptr to the implementation type.
// If the tab is not a TerminalTab, nullptr
winrt::com_ptr<TerminalTab> TerminalPage::_GetTerminalTabImpl(const ITab& tab) const
{
if (auto terminalTab = tab.try_as<TerminalApp::TerminalTab>())
{
winrt::com_ptr<TerminalTab> tabImpl;
tabImpl.copy_from(winrt::get_self<TerminalTab>(terminalTab));
return tabImpl;
}
else
{
return nullptr;
}
}

// Method Description:
// - The TabView does not apply compact sizing to items added after Compact is enabled.
// By forcibly reapplying compact sizing every time we add a new tab, we'll make sure
// that it works.
// Workaround from https://github.com/microsoft/microsoft-ui-xaml/issues/2711
// TODO: Remove this function and its calls when ingesting the above changes.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::_ReapplyCompactTabSize()
{
if (_tabView.TabWidthMode() == MUX::Controls::TabViewWidthMode::Compact)
{
_tabView.UpdateLayout();
_tabView.TabWidthMode(MUX::Controls::TabViewWidthMode::Compact);
}
}

// Method Description:
// - Initializes a SwitchToTab command object for this Tab instance.
// This should be done before the tab is added to the _tabs vector so that
// controls like the CmdPal that observe the vector changes can always expect
// a SwitchToTab command to be available.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TerminalPage::_MakeSwitchToTabCommand(const ITab& tab, const uint32_t index)
{
SwitchToTabArgs args{ index };
ActionAndArgs focusTabAction{ ShortcutAction::SwitchToTab, args };

Command command;
command.Action(focusTabAction);
command.Name(tab.Title());
command.IconSource(tab.IconSource());

tab.SwitchToTabCommand(command);
}

// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you.
Expand Down
38 changes: 19 additions & 19 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the MIT License. See LICENSE in the project root for license information. -->
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Color schemes"
<TextBlock x:Uid="ColorScheme_ColorSchemes"
Style="{StaticResource SubheaderTextBlockStyle}"
Margin="0,0,0,20"
Grid.Row="0" />
Expand All @@ -46,7 +46,7 @@ the MIT License. See LICENSE in the project root for license information. -->
Grid.Column="0">
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Background"
<TextBox x:Uid="ColorScheme_Background"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BackgroundHexValue, Mode=TwoWay}" />
Expand All @@ -71,7 +71,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Black"
<TextBox x:Uid="ColorScheme_Black"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BlackHexValue, Mode=TwoWay}" />
Expand All @@ -96,7 +96,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Blue"
<TextBox x:Uid="ColorScheme_Blue"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BlueHexValue, Mode=TwoWay}" />
Expand All @@ -121,7 +121,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Cyan"
<TextBox x:Uid="ColorScheme_Cyan"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.CyanHexValue, Mode=TwoWay}" />
Expand All @@ -146,7 +146,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Green"
<TextBox x:Uid="ColorScheme_Green"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.GreenHexValue, Mode=TwoWay}" />
Expand All @@ -171,7 +171,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Purple"
<TextBox x:Uid="ColorScheme_Purple"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.PurpleHexValue, Mode=TwoWay}" />
Expand All @@ -196,7 +196,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Red"
<TextBox x:Uid="ColorScheme_Red"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.RedHexValue, Mode=TwoWay}" />
Expand All @@ -221,7 +221,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="White"
<TextBox x:Uid="ColorScheme_White"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.WhiteHexValue, Mode=TwoWay}" />
Expand All @@ -246,7 +246,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Yellow"
<TextBox x:Uid="ColorScheme_Yellow"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.YellowHexValue, Mode=TwoWay}" />
Expand Down Expand Up @@ -274,7 +274,7 @@ the MIT License. See LICENSE in the project root for license information. -->
Grid.Column="1">
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Foreground"
<TextBox x:Uid="ColorScheme_Foreground"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.ForegroundHexValue, Mode=TwoWay}" />
Expand All @@ -299,7 +299,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Black"
<TextBox x:Uid="ColorScheme_BrightBlack"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightBlackHexValue, Mode=TwoWay}" />
Expand All @@ -324,7 +324,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Blue"
<TextBox x:Uid="ColorScheme_BrightBlue"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightBlueHexValue, Mode=TwoWay}" />
Expand All @@ -349,7 +349,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Cyan"
<TextBox x:Uid="ColorScheme_BrightCyan"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightCyanHexValue, Mode=TwoWay}" />
Expand All @@ -374,7 +374,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Green"
<TextBox x:Uid="ColorScheme_BrightGreen"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightGreenHexValue, Mode=TwoWay}" />
Expand All @@ -399,7 +399,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Purple"
<TextBox x:Uid="ColorScheme_BrightPurple"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightPurpleHexValue, Mode=TwoWay}" />
Expand All @@ -424,7 +424,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Red"
<TextBox x:Uid="ColorScheme_BrightRed"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightRedHexValue, Mode=TwoWay}" />
Expand All @@ -449,7 +449,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright White"
<TextBox x:Uid="ColorScheme_BrightWhite"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightWhiteHexValue, Mode=TwoWay}" />
Expand All @@ -474,7 +474,7 @@ the MIT License. See LICENSE in the project root for license information. -->
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,0,0,20">
<TextBox Header="Bright Yellow"
<TextBox x:Uid="ColorScheme_BrightYellow"
Width="100"
FontSize="15"
Text="{x:Bind ColorSchemeModel.ColorScheme.BrightYellowHexValue, Mode=TwoWay}" />
Expand Down
26 changes: 13 additions & 13 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ the MIT License. See LICENSE in the project root for license information. -->
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Global Appearance"
<TextBlock x:Uid="Globals_GlobalAppearance"
Style="{StaticResource SubheaderTextBlockStyle}"
Margin="0,0,0,20" />
<StackPanel Grid.Row="1" Grid.Column="0" Margin="0,0,100,0">
<Controls:RadioButtons Header="Theme" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="Sets the theme of the application. The value 'system' refers to the active Windows system theme." ToolTipService.Placement="Mouse">
<RadioButton x:Name="DefaultTheme" Content="Default"/>
<RadioButton x:Name="DarkTheme" Content="Dark"/>
<RadioButton x:Name="LightTheme" Content="Light"/>
<Controls:RadioButtons x:Uid="Globals_Theme" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse">
<RadioButton x:Uid="Globals_ThemeDefault" x:Name="DefaultTheme"/>
<RadioButton x:Uid="Globals_ThemeDark" x:Name="DarkTheme"/>
<RadioButton x:Uid="Globals_ThemeLight" x:Name="LightTheme"/>
</Controls:RadioButtons>
<CheckBox IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ShowTitlebar, Mode=TwoWay}" Content="Show the title bar" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="When checked, the tabs are moved into the title bar and the title bar disappears. When unchecked, the title bar sits above the tabs." ToolTipService.Placement="Mouse" />
<CheckBox IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ShowTitleInTitlebar, Mode=TwoWay}" Content="Show terminal title in title bar" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="When checked, the title bar displays the title of the selected tab. When unchecked, the title bar displays 'Windows Terminal'." ToolTipService.Placement="Mouse" />
<CheckBox IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.AlwaysShowTabs, Mode=TwoWay}" Content="Always show tabs" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="When checked, tabs are always displayed. When unchecked and 'show the title bar' is checked, tabs only appear after opening a new tab." ToolTipService.Placement="Mouse" />
<Controls:RadioButtons Header="Tab width mode" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="Sets the width of the tabs. 'Equal' sizes each tab to the same width. 'Title length' sizes each tab to the length of its title. 'Compact' sizes each tab to the length of its title when focused, and shrinks to the size of only the icon when the tab is unfocused." ToolTipService.Placement="Mouse">
<RadioButton x:Name="EqualTabWidthMode" Content="Equal"/>
<RadioButton x:Name="TitleLengthTabWidthMode" Content="Title length"/>
<RadioButton x:Name="CompactTabWidthMode" Content="Compact"/>
<CheckBox x:Uid="Globals_ShowTitlebar" IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ShowTitlebar, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
<CheckBox x:Uid="Globals_ShowTitleInTitlebar" IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ShowTitleInTitlebar, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
<CheckBox x:Uid="Globals_AlwaysShowTabs" IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.AlwaysShowTabs, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
<Controls:RadioButtons x:Uid="Globals_TabWidthMode" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse">
<RadioButton x:Uid="Globals_TabWidthModeEqual" x:Name="EqualTabWidthMode"/>
<RadioButton x:Uid="Globals_TabWidthModeTitleLength" x:Name="TitleLengthTabWidthMode"/>
<RadioButton x:Uid="Globals_TabWidthModeCompact" x:Name="CompactTabWidthMode"/>
</Controls:RadioButtons>
<CheckBox IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ConfirmCloseAllTabs, Mode=TwoWay}" Content="Show close all tabs popup" Margin="0,0,0,20" FontSize="15" ToolTipService.ToolTip="When checked, closing a window with multiple tabs open will require confirmation. When unchecked, the confirmation dialog will not appear." ToolTipService.Placement="Mouse" />
<CheckBox x:Uid="Globals_ConfirmCloseAllTabs" IsChecked="{x:Bind GlobalSettingsModel.GlobalSettings.ConfirmCloseAllTabs, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
</StackPanel>
</Grid>
</Page>
Loading

1 comment on commit 8b402c5

@github-actions

This comment was marked as resolved.

Please sign in to comment.