From 1ad16ade868a2b28390a848613c4af5a47f6a92b Mon Sep 17 00:00:00 2001 From: Alekhya Date: Wed, 22 Jan 2020 09:43:49 -0800 Subject: [PATCH] Localize the Shortcut guide PowerToy (#199) (#1126) * Localized shortcut_guide.cpp * localized overlay_window.cpp * formatting changes * Localize overlay window * removed the README link from the set of localized resources * Typo: changed upper to lower --- src/modules/shortcut_guide/overlay_window.cpp | 83 ++++++++++--------- src/modules/shortcut_guide/resource.h | 24 ++++-- src/modules/shortcut_guide/shortcut_guide.cpp | 6 +- src/modules/shortcut_guide/shortcut_guide.h | 1 + src/modules/shortcut_guide/shortcut_guide.rc | 16 +++- 5 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/modules/shortcut_guide/overlay_window.cpp b/src/modules/shortcut_guide/overlay_window.cpp index f1dca2c10f..e986a47d8b 100644 --- a/src/modules/shortcut_guide/overlay_window.cpp +++ b/src/modules/shortcut_guide/overlay_window.cpp @@ -6,8 +6,11 @@ #include "keyboard_state.h" #include "shortcut_guide.h" #include "trace.h" +#include "resource.h" #include +extern "C" IMAGE_DOS_HEADER __ImageBase; + D2DOverlaySVG& D2DOverlaySVG::load(const std::wstring& filename, ID2D1DeviceContext5* d2d_dc) { D2DSVG::load(filename, d2d_dc); @@ -791,71 +794,71 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc) switch (window_state) { case MINIMIZED: - left = L"No action"; + left = GET_RESOURCE_STRING(IDS_NO_ACTION); left_disabled = true; - right = L"No action"; + right = GET_RESOURCE_STRING(IDS_NO_ACTION); right_disabled = true; - up = L"Restore"; - down = L"No action"; + up = GET_RESOURCE_STRING(IDS_RESTORE); + down = GET_RESOURCE_STRING(IDS_NO_ACTION); down_disabled = true; break; case MAXIMIZED: - left = L"Snap left"; - right = L"Snap right"; - up = L"No action"; + left = GET_RESOURCE_STRING(IDS_SNAP_LEFT); + right = GET_RESOURCE_STRING(IDS_SNAP_RIGHT); + up = GET_RESOURCE_STRING(IDS_NO_ACTION); up_disabled = true; - down = L"Restore"; + down = GET_RESOURCE_STRING(IDS_RESTORE); break; case SNAPED_TOP_LEFT: - left = L"Snap upper right"; - right = L"Snap upper right"; - up = L"Maximize"; - down = L"Snap left"; + left = GET_RESOURCE_STRING(IDS_SNAP_UPPER_RIGHT); + right = GET_RESOURCE_STRING(IDS_SNAP_UPPER_RIGHT); + up = GET_RESOURCE_STRING(IDS_MAXIMIZE); + down = GET_RESOURCE_STRING(IDS_SNAP_LEFT); break; case SNAPED_LEFT: - left = L"Snap right"; - right = L"Restore"; - up = L"Snap upper left"; - down = L"Snap lower left"; + left = GET_RESOURCE_STRING(IDS_SNAP_RIGHT); + right = GET_RESOURCE_STRING(IDS_RESTORE); + up = GET_RESOURCE_STRING(IDS_SNAP_UPPER_LEFT); + down = GET_RESOURCE_STRING(IDS_SNAP_LOWER_LEFT); break; case SNAPED_BOTTOM_LEFT: - left = L"Snap lower right"; - right = L"Snap lower right"; - up = L"Snap left"; - down = L"Minimize"; + left = GET_RESOURCE_STRING(IDS_SNAP_LOWER_RIGHT); + right = GET_RESOURCE_STRING(IDS_SNAP_LOWER_RIGHT); + up = GET_RESOURCE_STRING(IDS_SNAP_LEFT); + down = GET_RESOURCE_STRING(IDS_MINIMIZE); break; case SNAPED_TOP_RIGHT: - left = L"Snap upper left"; - right = L"Snap upper left"; - up = L"Maximize"; - down = L"Snap right"; + left = GET_RESOURCE_STRING(IDS_SNAP_UPPER_LEFT); + right = GET_RESOURCE_STRING(IDS_SNAP_UPPER_LEFT); + up = GET_RESOURCE_STRING(IDS_MAXIMIZE); + down = GET_RESOURCE_STRING(IDS_SNAP_RIGHT); break; case SNAPED_RIGHT: - left = L"Restore"; - right = L"Snap left"; - up = L"Snap upper right"; - down = L"Snap lower right"; + left = GET_RESOURCE_STRING(IDS_RESTORE); + right = GET_RESOURCE_STRING(IDS_SNAP_LEFT); + up = GET_RESOURCE_STRING(IDS_SNAP_UPPER_RIGHT); + down = GET_RESOURCE_STRING(IDS_SNAP_LOWER_RIGHT); break; case SNAPED_BOTTOM_RIGHT: - left = L"Snap lower left"; - right = L"Snap lower left"; - up = L"Snap right"; - down = L"Minimize"; + left = GET_RESOURCE_STRING(IDS_SNAP_LOWER_LEFT); + right = GET_RESOURCE_STRING(IDS_SNAP_LOWER_LEFT); + up = GET_RESOURCE_STRING(IDS_SNAP_RIGHT); + down = GET_RESOURCE_STRING(IDS_MINIMIZE); break; case RESTORED: - left = L"Snap left"; - right = L"Snap right"; - up = L"Maximize"; - down = L"Minimize"; + left = GET_RESOURCE_STRING(IDS_SNAP_LEFT); + right = GET_RESOURCE_STRING(IDS_SNAP_RIGHT); + up = GET_RESOURCE_STRING(IDS_MAXIMIZE); + down = GET_RESOURCE_STRING(IDS_MINIMIZE); break; default: - left = L"No action"; + left = GET_RESOURCE_STRING(IDS_NO_ACTION); left_disabled = true; - right = L"No action"; + right = GET_RESOURCE_STRING(IDS_NO_ACTION); right_disabled = true; - up = L"No action"; + up = GET_RESOURCE_STRING(IDS_NO_ACTION); up_disabled = true; - down = L"No action"; + down = GET_RESOURCE_STRING(IDS_NO_ACTION); down_disabled = true; } auto text_color = D2D1::ColorF(light_mode ? 0x222222 : 0xDDDDDD, minature_shown || window_state == MINIMIZED ? 1.0f : 0.3f); diff --git a/src/modules/shortcut_guide/resource.h b/src/modules/shortcut_guide/resource.h index 8ebca8b261..3c5e7ead2e 100644 --- a/src/modules/shortcut_guide/resource.h +++ b/src/modules/shortcut_guide/resource.h @@ -1,6 +1,18 @@ -#define IDS_SETTING_DESCRIPTION_PRESS_TIME 101 -#define IDS_SETTING_DESCRIPTION_OVERLAY_OPACITY 102 -#define IDS_SETTING_DESCRIPTION_THEME 103 -#define IDS_SETTING_DESCRIPTION_THEME_LIGHT 104 -#define IDS_SETTING_DESCRIPTION_THEME_DARK 105 -#define IDS_SETTING_DESCRIPTION_THEME_SYSTEM 106 +#define IDS_SETTING_DESCRIPTION_PRESS_TIME 101 +#define IDS_SETTING_DESCRIPTION_OVERLAY_OPACITY 102 +#define IDS_SETTING_DESCRIPTION_THEME 103 +#define IDS_SETTING_DESCRIPTION_THEME_LIGHT 104 +#define IDS_SETTING_DESCRIPTION_THEME_DARK 105 +#define IDS_SETTING_DESCRIPTION_THEME_SYSTEM 106 +#define IDS_SETTINGS_DESCRIPTION 107 +#define IDS_SHORTCUT_GUIDE 108 +#define IDS_NO_ACTION 109 +#define IDS_RESTORE 110 +#define IDS_SNAP_RIGHT 111 +#define IDS_SNAP_LEFT 112 +#define IDS_SNAP_UPPER_RIGHT 113 +#define IDS_SNAP_UPPER_LEFT 114 +#define IDS_SNAP_LOWER_RIGHT 115 +#define IDS_SNAP_LOWER_LEFT 116 +#define IDS_MINIMIZE 117 +#define IDS_MAXIMIZE 118 diff --git a/src/modules/shortcut_guide/shortcut_guide.cpp b/src/modules/shortcut_guide/shortcut_guide.cpp index cff08e6bca..c9ac087659 100644 --- a/src/modules/shortcut_guide/shortcut_guide.cpp +++ b/src/modules/shortcut_guide/shortcut_guide.cpp @@ -2,6 +2,7 @@ #include "shortcut_guide.h" #include "target_state.h" #include "trace.h" +#include "resource.h" #include #include @@ -12,12 +13,13 @@ OverlayWindow* instance = nullptr; OverlayWindow::OverlayWindow() { + app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE); init_settings(); } const wchar_t* OverlayWindow::get_name() { - return L"Shortcut Guide"; + return app_name.c_str(); } const wchar_t** OverlayWindow::get_events() @@ -31,7 +33,7 @@ bool OverlayWindow::get_config(wchar_t* buffer, int* buffer_size) HINSTANCE hinstance = reinterpret_cast(&__ImageBase); PowerToysSettings::Settings settings(hinstance, get_name()); - settings.set_description(L"Shows a help overlay with Windows shortcuts when the Windows key is pressed."); + settings.set_description(GET_RESOURCE_STRING(IDS_SETTINGS_DESCRIPTION)); settings.set_overview_link(L"https://github.com/microsoft/PowerToys/blob/master/src/modules/shortcut_guide/README.md"); settings.set_icon_key(L"pt-shortcut-guide"); diff --git a/src/modules/shortcut_guide/shortcut_guide.h b/src/modules/shortcut_guide/shortcut_guide.h index c16125538e..61d0691e5b 100644 --- a/src/modules/shortcut_guide/shortcut_guide.h +++ b/src/modules/shortcut_guide/shortcut_guide.h @@ -35,6 +35,7 @@ public: virtual void destroy() override; private: + std::wstring app_name; std::unique_ptr target_state; std::unique_ptr winkey_popup; bool _enabled = false; diff --git a/src/modules/shortcut_guide/shortcut_guide.rc b/src/modules/shortcut_guide/shortcut_guide.rc index e32a73a02d..e55ce78a6f 100644 --- a/src/modules/shortcut_guide/shortcut_guide.rc +++ b/src/modules/shortcut_guide/shortcut_guide.rc @@ -7,8 +7,20 @@ IDS_SETTING_DESCRIPTION_OVERLAY_OPACITY "Opacity of the Shortcut Guide's overlay background (%)" IDS_SETTING_DESCRIPTION_THEME "Choose Shortcut Guide overlay color" IDS_SETTING_DESCRIPTION_THEME_LIGHT "Light" - IDS_SETTING_DESCRIPTION_THEME_DARK "Dark" - IDS_SETTING_DESCRIPTION_THEME_SYSTEM "System default app mode" + IDS_SETTING_DESCRIPTION_THEME_DARK "Dark" + IDS_SETTING_DESCRIPTION_THEME_SYSTEM "System default app mode" + IDS_SETTINGS_DESCRIPTION L"Shows a help overlay with Windows shortcuts when the Windows key is pressed." + IDS_SHORTCUT_GUIDE L"Shortcut Guide" + IDS_NO_ACTION L"No action" + IDS_RESTORE L"Restore" + IDS_SNAP_RIGHT L"Snap right" + IDS_SNAP_LEFT L"Snap left" + IDS_SNAP_UPPER_RIGHT L"Snap upper right" + IDS_SNAP_UPPER_LEFT L"Snap upper left" + IDS_SNAP_LOWER_RIGHT L"Snap lower right" + IDS_SNAP_LOWER_LEFT L"Snap lower left" + IDS_MINIMIZE L"Minimize" + IDS_MAXIMIZE L"Maximize" END 1 VERSIONINFO