Skip to content

Commit

Permalink
Localize the Shortcut guide PowerToy (microsoft#199) (microsoft#1126)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alekhyareddy28 authored and udit3333 committed Feb 19, 2020
1 parent 0203dc4 commit 495f725
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 48 deletions.
83 changes: 43 additions & 40 deletions src/modules/shortcut_guide/overlay_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 18 additions & 6 deletions src/modules/shortcut_guide/resource.h
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions src/modules/shortcut_guide/shortcut_guide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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()
Expand All @@ -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");

Expand Down
1 change: 1 addition & 0 deletions src/modules/shortcut_guide/shortcut_guide.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OverlayWindow : public PowertoyModuleIface
virtual void destroy() override;

private:
std::wstring app_name;
std::unique_ptr<TargetState> target_state;
std::unique_ptr<D2DOverlayWindow> winkey_popup;
bool _enabled = false;
Expand Down
Binary file modified src/modules/shortcut_guide/shortcut_guide.rc
Binary file not shown.

0 comments on commit 495f725

Please sign in to comment.