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

Localize PowerRename #1106

Merged
merged 17 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, const wch
// Requires that
// extern "C" IMAGE_DOS_HEADER __ImageBase;
// is added to the .cpp file.
#define GET_RESOURCE_STRING(resource_id) get_resource_string(resource_id, reinterpret_cast<HINSTANCE>(&__ImageBase), L#resource_id)
#define GET_RESOURCE_STRING(resource_id) get_resource_string(resource_id, reinterpret_cast<HINSTANCE>(&__ImageBase), L#resource_id)
4 changes: 3 additions & 1 deletion src/modules/powerrename/dll/PowerRenameExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <PowerRenameItem.h>
#include <PowerRenameManager.h>
#include <trace.h>
#include <common.h>
#include <Helpers.h>
#include <icon_helpers.h>
#include <Settings.h>
Expand All @@ -20,6 +21,7 @@ struct InvokeStruct
CPowerRenameMenu::CPowerRenameMenu()
{
ModuleAddRef();
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME);
}

CPowerRenameMenu::~CPowerRenameMenu()
Expand Down Expand Up @@ -196,7 +198,7 @@ DWORD WINAPI CPowerRenameMenu::s_PowerRenameUIThreadProc(_In_ void* pData)

HRESULT __stdcall CPowerRenameMenu::GetTitle(IShellItemArray* /*psiItemArray*/, LPWSTR* ppszName)
{
return SHStrDup(L"PowerRename", ppszName);
return SHStrDup(app_name.c_str(), ppszName);
}

HRESULT __stdcall CPowerRenameMenu::GetIcon(IShellItemArray* /*psiItemArray*/, LPWSTR* ppszIcon)
Expand Down
1 change: 1 addition & 0 deletions src/modules/powerrename/dll/PowerRenameExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ class __declspec(uuid("0440049F-D1DC-4E46-B27B-98393D79486B")) CPowerRenameMenu
std::atomic<long> m_refCount = 1;
HBITMAP m_hbmpIcon = nullptr;
CComPtr<IDataObject> m_spdo;
std::wstring app_name;
};
Binary file modified src/modules/powerrename/dll/PowerRenameExt.rc
Binary file not shown.
23 changes: 14 additions & 9 deletions src/modules/powerrename/dll/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <settings.h>
#include <trace.h>
#include <common/settings_objects.h>

#include <common/common.h>
#include "resource.h"
#include <atomic>

std::atomic<DWORD> g_dwModuleRefCount = 0;
Expand Down Expand Up @@ -160,12 +161,13 @@ class PowerRenameModule : public PowertoyModuleIface
private:
// Enabled by default
bool m_enabled = true;
std::wstring app_name;

public:
// Return the display name of the powertoy, this will be cached
virtual PCWSTR get_name() override
{
return L"PowerRename";
return app_name.c_str();
}

// Enable the powertoy
Expand Down Expand Up @@ -203,38 +205,38 @@ class PowerRenameModule : public PowertoyModuleIface

// Create a Settings object.
PowerToysSettings::Settings settings(hinstance, get_name());
settings.set_description(L"A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions.");
settings.set_description(GET_RESOURCE_STRING(IDS_SETTINGS_DESCRIPTION));
settings.set_icon_key(L"pt-power-rename");

// Link to the GitHub PowerRename sub-page
settings.set_overview_link(L"https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename");
settings.set_overview_link(GET_RESOURCE_STRING(IDS_OVERVIEW_LINK));

settings.add_bool_toogle(
L"bool_persist_input",
L"Restore search, replace and flags values on launch from previous run.",
GET_RESOURCE_STRING(IDS_RESTORE_SEARCH),
CSettings::GetPersistState());

settings.add_bool_toogle(
L"bool_mru_enabled",
L"Enable autocomplete and autosuggest of recently used inputs for search and replace values.",
GET_RESOURCE_STRING(IDS_ENABLE_AUTO),
CSettings::GetMRUEnabled());

settings.add_int_spinner(
L"int_max_mru_size",
L"Maximum number of items to show in recently used list for autocomplete dropdown.",
GET_RESOURCE_STRING(IDS_MAX_ITEMS),
CSettings::GetMaxMRUSize(),
0,
20,
1);

settings.add_bool_toogle(
L"bool_show_icon_on_menu",
L"Show icon on context menu.",
GET_RESOURCE_STRING(IDS_ICON_CONTEXT_MENU),
CSettings::GetShowIconOnMenu());

settings.add_bool_toogle(
L"bool_show_extended_menu",
L"Only show the PowerRename menu item on the extended context menu (SHIFT + Right-click).",
GET_RESOURCE_STRING(IDS_EXTENDED_MENU_INFO),
CSettings::GetExtendedContextMenuOnly());

return settings.serialize_to_buffer(buffer, buffer_size);
Expand Down Expand Up @@ -298,7 +300,10 @@ class PowerRenameModule : public PowertoyModuleIface
PowerRenameModule()
{
init_settings();
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME);
}

~PowerRenameModule(){};
};

extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
Expand Down
19 changes: 14 additions & 5 deletions src/modules/powerrename/dll/resource.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#define IDS_POWERRENAME 801
#define IDI_RENAME 132
#define IDS_SETTINGS_DESCRIPTION 2101
#define IDS_OVERVIEW_LINK 2102
#define IDS_RESTORE_SEARCH 2103
#define IDS_ENABLE_AUTO 2104
#define IDS_MAX_ITEMS 2105
#define IDS_ICON_CONTEXT_MENU 2106
#define IDS_EXTENDED_MENU_INFO 2107

// Next default values for new objects
//

//

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
1 change: 0 additions & 1 deletion src/modules/powerrename/lib/Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "stdafx.h"
#include <commctrl.h>
#include "Settings.h"
Expand Down
1 change: 1 addition & 0 deletions src/modules/powerrename/testapp/PowerRenameTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <PowerRenameUI.h>
#include <PowerRenameManager.h>
#include <Shobjidl.h>
#include <common.h>

#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Expand Down