diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp index a2b13bf60b9..e81578a48d6 100644 --- a/support/hololens/ServoApp/BrowserPage.cpp +++ b/support/hololens/ServoApp/BrowserPage.cpp @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "pch.h" -#include "logs.h" +#include "strutils.h" #include "BrowserPage.h" #include "BrowserPage.g.cpp" #include "DefaultUrl.h" @@ -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; @@ -103,7 +104,7 @@ void BrowserPage::LoadServoURI(Uri uri) { auto scheme = uri.SchemeName(); if (scheme != SERVO_SCHEME) { - log("Unexpected URL: ", uri.RawUri().c_str()); + log(L"Unexpected URL: ", uri.RawUri().c_str()); return; } std::wstring raw{uri.RawUri()}; @@ -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().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")); } } diff --git a/support/hololens/ServoApp/BrowserPage.xaml b/support/hololens/ServoApp/BrowserPage.xaml index da4ea5c9792..7954ad828e4 100644 --- a/support/hololens/ServoApp/BrowserPage.xaml +++ b/support/hololens/ServoApp/BrowserPage.xaml @@ -9,8 +9,6 @@ xmlns:muxc="using:Microsoft.UI.Xaml.Controls" mc:Ignorable="d"> - -