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
This commit is contained in:
Alekhya 2020-01-22 09:43:49 -08:00 committed by GitHub
parent 45e3f02832
commit 1ad16ade86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 50 deletions

View File

@ -6,8 +6,11 @@
#include "keyboard_state.h"
#include "shortcut_guide.h"
#include "trace.h"
#include "resource.h"
#include <common/common.h>
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);

View File

@ -4,3 +4,15 @@
#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

View File

@ -2,6 +2,7 @@
#include "shortcut_guide.h"
#include "target_state.h"
#include "trace.h"
#include "resource.h"
#include <common/common.h>
#include <common/settings_objects.h>
@ -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<HINSTANCE>(&__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");

View File

@ -35,6 +35,7 @@ public:
virtual void destroy() override;
private:
std::wstring app_name;
std::unique_ptr<TargetState> target_state;
std::unique_ptr<D2DOverlayWindow> winkey_popup;
bool _enabled = false;

View File

@ -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