Skip to content
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

UWP L10N #26840

Merged
merged 3 commits into from Jun 11, 2020
Merged

UWP L10N #26840

Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

L10N for UWP app.

  • Loading branch information
paulrouget committed Jun 11, 2020
commit e5edd22208f5e59ef320482e991c96676c9b4967
@@ -19,6 +19,7 @@ using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::ViewManagement;
using namespace winrt::Windows::ApplicationModel::Core;
using namespace winrt::Windows::ApplicationModel::Resources;
using namespace winrt::Windows::UI::Notifications;
using namespace winrt::Windows::Data::Xml::Dom;

@@ -181,6 +182,9 @@ void BrowserPage::BuildPrefList() {
// it's pretty difficiult to have different controls depending
// on the pref type.
prefList().Children().Clear();
auto resourceLoader = ResourceLoader::GetForCurrentView();
auto resetStr =
resourceLoader.GetString(L"devtoolsPreferenceResetButton/Content");
for (auto pref : ServoControl().Preferences()) {
auto value = pref.Value();
auto type = value.as<IPropertyValue>().Type();
@@ -244,7 +248,7 @@ void BrowserPage::BuildPrefList() {
ctrl->Margin({4, 0, 40, 0});
stack.Children().Append(*ctrl);
auto reset = Controls::Button();
reset.Content(winrt::box_value(L"reset"));
reset.Content(winrt::box_value(resetStr));
reset.IsEnabled(!pref.IsDefault());
reset.Click([=](const auto &, auto const &) {
auto upref = ServoControl().ResetPref(pref.Key());
@@ -284,18 +288,19 @@ void BrowserPage::OnDevtoolsButtonClicked(IInspectable const &,

BuildPrefList();

// FIXME: we could use template + binding for this.
auto ok = mDevtoolsStatus == DevtoolsStatus::Running ? Visibility::Visible
: Visibility::Collapsed;
auto ko = mDevtoolsStatus == DevtoolsStatus::Failed ? Visibility::Visible
: Visibility::Collapsed;
auto wip = mDevtoolsStatus == DevtoolsStatus::Stopped ? Visibility::Visible
: Visibility::Collapsed;
DevtoolsStatusOK().Visibility(ok);
DevtoolsStatusKO().Visibility(ko);
DevtoolsStatusWIP().Visibility(wip);
auto resourceLoader = ResourceLoader::GetForCurrentView();
if (mDevtoolsStatus == DevtoolsStatus::Running) {
DevtoolsPort().Text(std::to_wstring(mDevtoolsPort));
std::wstring message =
resourceLoader.GetString(L"devtoolsStatus/Running").c_str();
std::wstring formatted =
format(message, std::to_wstring(mDevtoolsPort).c_str());
DevtoolsStatusMessage().Text(formatted);
} else if (mDevtoolsStatus == DevtoolsStatus::Failed) {
DevtoolsStatusMessage().Text(
resourceLoader.GetString(L"devtoolsStatus/Failed"));
} else if (mDevtoolsStatus == DevtoolsStatus::Stopped) {
DevtoolsStatusMessage().Text(
resourceLoader.GetString(L"devtoolsStatus/Stopped"));
}
}

@@ -9,8 +9,6 @@
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">



<Page.Resources>
<Style x:Key="NavigationBarButton" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
@@ -98,41 +96,41 @@
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0">
<Button Style="{StaticResource NavigationBarButton}" x:Name="backButton" IsTabStop="true" IsEnabled="false" Click="OnBackButtonClicked" AutomationProperties.Name="Back" ToolTipService.ToolTip="Back">
<Button Style="{StaticResource NavigationBarButton}" x:Uid="backButton" x:Name="backButton" IsTabStop="true" IsEnabled="false" Click="OnBackButtonClicked">
<Image Source="Assets/UI/back.png" Height="18"></Image>
<Button.KeyboardAccelerators>
<KeyboardAccelerator Key="Left" Modifiers="Menu" />
</Button.KeyboardAccelerators>
</Button>
<Button Style="{StaticResource NavigationBarButton}" x:Name="forwardButton" IsTabStop="true" IsEnabled="false" Click="OnForwardButtonClicked" AutomationProperties.Name="Forward" ToolTipService.ToolTip="Forward">
<Button Style="{StaticResource NavigationBarButton}" x:Uid="forwardButton" x:Name="forwardButton" IsTabStop="true" IsEnabled="false" Click="OnForwardButtonClicked">
<Image Source="Assets/UI/forward.png" Height="18"></Image>
<Button.KeyboardAccelerators>
<KeyboardAccelerator Key="Right" Modifiers="Menu" />
</Button.KeyboardAccelerators>
</Button>
<Button Style="{StaticResource NavigationBarButton}" x:Name="reloadButton" IsTabStop="true" IsEnabled="false" Visibility="Visible" Click="OnReloadButtonClicked" AutomationProperties.Name="Reload" ToolTipService.ToolTip="Reload">
<Button Style="{StaticResource NavigationBarButton}" x:Name="reloadButton" x:Uid="reloadButton" IsTabStop="true" IsEnabled="false" Visibility="Visible" Click="OnReloadButtonClicked">
<Image Source="Assets/UI/reload.png" Height="18"></Image>
<Button.KeyboardAccelerators>
<KeyboardAccelerator Key="R" Modifiers="Control" />
</Button.KeyboardAccelerators>
</Button>
<Button Style="{StaticResource NavigationBarButton}" x:Name="stopButton" IsTabStop="true" IsEnabled="false" Visibility="Collapsed" Click="OnStopButtonClicked" AutomationProperties.Name="Stop" ToolTipService.ToolTip="Stop">
<Button Style="{StaticResource NavigationBarButton}" x:Name="stopButton" x:Uid="stopButton" IsTabStop="true" IsEnabled="false" Visibility="Collapsed" Click="OnStopButtonClicked">
<Image Source="Assets/UI/cross.png" Height="18"></Image>
<Button.KeyboardAccelerators>
<KeyboardAccelerator Key="Escape" Modifiers="None" />
</Button.KeyboardAccelerators>
</Button>
<Button Style="{StaticResource NavigationBarButton}" x:Name="homeButton" IsTabStop="true" Click="OnHomeButtonClicked" AutomationProperties.Name="Home" ToolTipService.ToolTip="Home">
<Button Style="{StaticResource NavigationBarButton}" x:Name="homeButton" x:Uid="homeButton" IsTabStop="true" Click="OnHomeButtonClicked">
<Image Source="Assets/UI/home.png" Height="18"></Image>
</Button>
</StackPanel>
<TextBox Text="" IsTabStop="true" InputScope="Url" PlaceholderText="Type a URL" x:Name="urlTextbox" VerticalAlignment="Center" Grid.Column="1" KeyUp="OnURLEdited" IsSpellCheckEnabled="False" Margin="3,0" KeyboardAcceleratorPlacementMode="Hidden">
<TextBox x:Uid="urlTextbox" Text="" IsTabStop="true" InputScope="Url" x:Name="urlTextbox" VerticalAlignment="Center" Grid.Column="1" KeyUp="OnURLEdited" IsSpellCheckEnabled="False" Margin="3,0" KeyboardAcceleratorPlacementMode="Hidden">
<TextBox.KeyboardAccelerators>
<KeyboardAccelerator Key="L" Modifiers="Control" Invoked="OnURLKeyboardAccelerator"/>
</TextBox.KeyboardAccelerators>
</TextBox>
<StackPanel Orientation="Horizontal" Grid.Column="2">
<Button Style="{StaticResource NavigationBarButton}" x:Name="devtoolsButton" IsTabStop="true" Click="OnDevtoolsButtonClicked" AutomationProperties.Name="Devtools" ToolTipService.ToolTip="Devtools">
<Button Style="{StaticResource NavigationBarButton}" x:Name="devtoolsButton" x:Uid="devtoolsButton" IsTabStop="true" Click="OnDevtoolsButtonClicked">
<Image Source="Assets/UI/devtools.png" Height="18"></Image>
</Button>
<ProgressRing x:Name="urlbarLoadingIndicator" Margin="10,0"/>
@@ -151,28 +149,16 @@
</Button>
</Grid>
</muxc:TabView.TabStripFooter>
<muxc:TabViewItem Header="Devtools Server" IsClosable="False">
<StackPanel>
<TextBlock x:Name="DevtoolsStatusOK" Visibility="Collapsed" Margin="10">
<Run>Devtools server is listening on port </Run>
<Run FontWeight="Bold" x:Name="DevtoolsPort"></Run>
<Run>.</Run>
</TextBlock>
<TextBlock x:Name="DevtoolsStatusKO" Visibility="Collapsed">
<Run>Devtools server failed to start.</Run>
</TextBlock>
<TextBlock x:Name="DevtoolsStatusWIP" Visibility="Collapsed">
<Run>Devtools server is starting..</Run>
</TextBlock>
</StackPanel>
<muxc:TabViewItem x:Uid="devtoolsTabServer" IsClosable="False">
<TextBlock x:Name="DevtoolsStatusMessage" Margin="10"></TextBlock>
</muxc:TabViewItem>
<muxc:TabViewItem Header="Preferences" IsClosable="False">
<muxc:TabViewItem x:Uid="devtoolsTabPrefs" IsClosable="False">
<Grid VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="" IsTabStop="true" PlaceholderText="Search preferences" x:Name="preferenceSearchbox" VerticalAlignment="Center" KeyUp="OnPrefererenceSearchboxEdited" IsSpellCheckEnabled="False" Margin="3"/>
<TextBox Grid.Row="0" IsTabStop="true" x:Uid="preferenceSearchbox" x:Name="preferenceSearchbox" VerticalAlignment="Center" KeyUp="OnPrefererenceSearchboxEdited" IsSpellCheckEnabled="False" Margin="3"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="prefList"/>
</ScrollViewer>
@@ -181,8 +167,8 @@
</muxc:TabView>
<ProgressBar x:Name="transientLoadingIndicator" Visibility="Collapsed" Grid.Row="3"/>
<CommandBar Grid.Row="4" x:Name="mediaControls" Visibility="Collapsed">
<AppBarButton Icon="Play" Label="Play" x:Name="playButton" Visibility="Collapsed" Click="OnMediaControlsPlayClicked"/>
<AppBarButton Icon="Pause" Label="Pause" x:Name="pauseButton" Click="OnMediaControlsPauseClicked"/>
<AppBarButton Icon="Play" x:Uid="playButton" x:Name="playButton" Visibility="Collapsed" Click="OnMediaControlsPlayClicked"/>
<AppBarButton Icon="Pause" x:Uid="pauseButton" x:Name="pauseButton" Click="OnMediaControlsPauseClicked"/>
</CommandBar>
</Grid>

@@ -16,7 +16,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ServoApp.App">
<uap:VisualElements DisplayName="Firefox Reality" Description="Firefox Reality brings the best and freshest content from the web that you know and love to Virtual Reality headsets. Our browser provides an open, accessible and secure way for everyone to explore the web. Experience sharp text, high quality videos, and a seamless transition from 2D to 3D immersive modes. Enjoy the best possible web browsing experience with Firefox Reality." Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" BackgroundColor="transparent">
<uap:VisualElements DisplayName="Firefox Reality" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" BackgroundColor="transparent" Description="ms-resource:appDescription">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" ShortName="Firefox Reality" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
@@ -942,6 +942,10 @@
</None>
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-US\Resources.resw" />
<PRIResource Include="Strings\fr-FR\Resources.resw" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
@@ -887,6 +887,15 @@
<Filter Include="Assets\UI">
<UniqueIdentifier>{d49fe329-5e22-4470-8310-5b925419e6f8}</UniqueIdentifier>
</Filter>
<Filter Include="Strings">
<UniqueIdentifier>{49e23631-d899-4caf-bf7b-30776fee4d09}</UniqueIdentifier>
</Filter>
<Filter Include="Strings\en-US">
<UniqueIdentifier>{c12ff5d4-3730-4a0e-8b16-56ded3138875}</UniqueIdentifier>
</Filter>
<Filter Include="Strings\fr-FR">
<UniqueIdentifier>{b7d3273d-a27c-4176-87a1-3d5222b796b3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
@@ -900,4 +909,12 @@
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-US\Resources.resw">
<Filter>Strings\en-US</Filter>
</PRIResource>
<PRIResource Include="Strings\fr-FR\Resources.resw">
<Filter>Strings\fr-FR</Filter>
</PRIResource>
</ItemGroup>
</Project>
@@ -6,6 +6,7 @@
#include <stdlib.h>

using namespace std::placeholders;
using namespace winrt::Windows::ApplicationModel::Resources;
using namespace winrt::Windows::Graphics::Display;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Popups;
@@ -22,6 +23,16 @@ ServoControl::ServoControl() {
mDPI = (float)DisplayInformation::GetForCurrentView().ResolutionScale() / 100;
DefaultStyleKey(winrt::box_value(L"ServoApp.ServoControl"));
Loaded(std::bind(&ServoControl::OnLoaded, this, _1, _2));

auto r = ResourceLoader::GetForCurrentView();
L10NStrings l10NStrings = {r.GetString(L"ContextMenu/title"),
r.GetString(L"JavascriptPrompt/title"),
r.GetString(L"JavascriptPrompt/ok"),
r.GetString(L"JavascriptPrompt/cancel"),
r.GetString(L"JavascriptPrompt/yes"),
r.GetString(L"JavascriptPrompt/no"),
r.GetString(L"URINotValid/Alert")};
mL10NStrings = std::make_unique<L10NStrings>(l10NStrings);
}

void ServoControl::Shutdown() {
@@ -278,9 +289,11 @@ hstring ServoControl::LoadURIOrSearch(hstring input) {

// Doesn't look like a URI. Let's search for the string.
auto escapedInput = Uri::EscapeComponent(input);
std::wstring searchUri = unbox_value<hstring>(std::get<1>(Servo::GetPref(L"shell.searchpage"))).c_str();
std::wstring formated = format(searchUri, escapedInput.c_str());
hstring finalUri{formated};
std::wstring searchUri =
unbox_value<hstring>(std::get<1>(Servo::GetPref(L"shell.searchpage")))
.c_str();
std::wstring formatted = format(searchUri, escapedInput.c_str());
hstring finalUri{formatted};
TryLoadUri(finalUri);
return finalUri;
}
@@ -299,7 +312,7 @@ void ServoControl::TryLoadUri(hstring input) {
RunOnGLThread([=] {
if (!mServo->LoadUri(input)) {
RunOnUIThread([=] {
MessageDialog msg{L"URI not valid"};
MessageDialog msg{mL10NStrings->URINotValid};
msg.ShowAsync();
});
}
@@ -509,14 +522,19 @@ ServoControl::PromptSync(hstring title, hstring message, hstring primaryButton,
}

void ServoControl::OnServoPromptAlert(winrt::hstring message, bool trusted) {
auto title = trusted ? L"" : mCurrentUrl + L" says:";
PromptSync(title, message, L"OK", {}, {});
auto titlefmt =
format(mL10NStrings->PromptTitle.c_str(), mCurrentUrl.c_str());
hstring title{trusted ? L"" : titlefmt};
PromptSync(title, message, mL10NStrings->PromptOk, {}, {});
}

Servo::PromptResult
ServoControl::OnServoPromptOkCancel(winrt::hstring message, bool trusted) {
auto title = trusted ? L"" : mCurrentUrl + L" says:";
auto [button, string] = PromptSync(title, message, L"OK", L"Cancel", {});
Servo::PromptResult ServoControl::OnServoPromptOkCancel(winrt::hstring message,
bool trusted) {
auto titlefmt =
format(mL10NStrings->PromptTitle.c_str(), mCurrentUrl.c_str());
hstring title{trusted ? L"" : titlefmt};
auto [button, string] = PromptSync(title, message, mL10NStrings->PromptOk,
mL10NStrings->PromptCancel, {});
if (button == Controls::ContentDialogResult::Primary) {
return Servo::PromptResult::Primary;
} else if (button == Controls::ContentDialogResult::Secondary) {
@@ -526,10 +544,13 @@ ServoControl::OnServoPromptOkCancel(winrt::hstring message, bool trusted) {
}
}

Servo::PromptResult
ServoControl::OnServoPromptYesNo(winrt::hstring message, bool trusted) {
auto title = trusted ? L"" : mCurrentUrl + L" says:";
auto [button, string] = PromptSync(title, message, L"Yes", L"No", {});
Servo::PromptResult ServoControl::OnServoPromptYesNo(winrt::hstring message,
bool trusted) {
auto titlefmt =
format(mL10NStrings->PromptTitle.c_str(), mCurrentUrl.c_str());
hstring title{trusted ? L"" : titlefmt};
auto [button, string] = PromptSync(title, message, mL10NStrings->PromptYes,
mL10NStrings->PromptNo, {});
if (button == Controls::ContentDialogResult::Primary) {
return Servo::PromptResult::Primary;
} else if (button == Controls::ContentDialogResult::Secondary) {
@@ -542,8 +563,11 @@ ServoControl::OnServoPromptYesNo(winrt::hstring message, bool trusted) {
std::optional<hstring> ServoControl::OnServoPromptInput(winrt::hstring message,
winrt::hstring default,
bool trusted) {
auto title = trusted ? L"" : mCurrentUrl + L" says:";
auto [button, string] = PromptSync(title, message, L"Ok", L"Cancel", default);
auto titlefmt =
format(mL10NStrings->PromptTitle.c_str(), mCurrentUrl.c_str());
hstring title{trusted ? L"" : titlefmt};
auto [button, string] = PromptSync(title, message, mL10NStrings->PromptOk,
mL10NStrings->PromptCancel, default);
return string;
}

@@ -558,7 +582,8 @@ void ServoControl::OnServoDevtoolsStarted(bool success,
void ServoControl::OnServoShowContextMenu(std::optional<hstring> title,
std::vector<winrt::hstring> items) {
RunOnUIThread([=] {
MessageDialog msg{title.value_or(L"Menu")};
auto titlestr = mL10NStrings->ContextMenuTitle;
MessageDialog msg{title.value_or(titlestr)};
for (auto i = 0; i < items.size(); i++) {
UICommand cmd{items[i], [=](auto) {
RunOnGLThread([=] {
@@ -568,7 +593,7 @@ void ServoControl::OnServoShowContextMenu(std::optional<hstring> title,
}};
msg.Commands().Append(cmd);
}
UICommand cancel{L"Cancel", [=](auto) {
UICommand cancel{mL10NStrings->PromptCancel, [=](auto) {
RunOnGLThread([=] {
mServo->ContextMenuClosed(
Servo::ContextMenuResult::Dismissed_, 0);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.