Merge pull request #1106 from alekhyareddy28/locPowerRename

Localize PowerRename
This commit is contained in:
Alekhya 2020-01-20 12:11:07 -08:00 committed by GitHub
commit ba1a681aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 18 deletions

View File

@ -77,4 +77,4 @@ std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, const wch
// Requires that // Requires that
// extern "C" IMAGE_DOS_HEADER __ImageBase; // extern "C" IMAGE_DOS_HEADER __ImageBase;
// is added to the .cpp file. // 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)

View File

@ -4,6 +4,7 @@
#include <PowerRenameItem.h> #include <PowerRenameItem.h>
#include <PowerRenameManager.h> #include <PowerRenameManager.h>
#include <trace.h> #include <trace.h>
#include <common.h>
#include <Helpers.h> #include <Helpers.h>
#include <icon_helpers.h> #include <icon_helpers.h>
#include <Settings.h> #include <Settings.h>
@ -20,6 +21,7 @@ struct InvokeStruct
CPowerRenameMenu::CPowerRenameMenu() CPowerRenameMenu::CPowerRenameMenu()
{ {
ModuleAddRef(); ModuleAddRef();
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME);
} }
CPowerRenameMenu::~CPowerRenameMenu() CPowerRenameMenu::~CPowerRenameMenu()
@ -196,7 +198,7 @@ DWORD WINAPI CPowerRenameMenu::s_PowerRenameUIThreadProc(_In_ void* pData)
HRESULT __stdcall CPowerRenameMenu::GetTitle(IShellItemArray* /*psiItemArray*/, LPWSTR* ppszName) 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) HRESULT __stdcall CPowerRenameMenu::GetIcon(IShellItemArray* /*psiItemArray*/, LPWSTR* ppszIcon)

View File

@ -71,4 +71,5 @@ private:
std::atomic<long> m_refCount = 1; std::atomic<long> m_refCount = 1;
HBITMAP m_hbmpIcon = nullptr; HBITMAP m_hbmpIcon = nullptr;
CComPtr<IDataObject> m_spdo; CComPtr<IDataObject> m_spdo;
std::wstring app_name;
}; };

View File

@ -91,7 +91,14 @@
STRINGTABLE STRINGTABLE
BEGIN BEGIN
IDS_POWERRENAME "PowerRename" IDS_POWERRENAME "PowerRename"
IDS_SETTINGS_DESCRIPTION L"A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions."
IDS_OVERVIEW_LINK L"https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"
IDS_RESTORE_SEARCH L"Restore search, replace and flags values on launch from previous run."
IDS_ENABLE_AUTO L"Enable autocomplete and autosuggest of recently used inputs for search and replace values."
IDS_MAX_ITEMS L"Maximum number of items to show in recently used list for autocomplete dropdown."
IDS_ICON_CONTEXT_MENU L"Show icon on context menu."
IDS_EXTENDED_MENU_INFO L"Only show the PowerRename menu item on the extended context menu (Shift + Right-click)."
END END
#endif // English (United States) resources #endif // English (United States) resources

View File

@ -4,7 +4,8 @@
#include <settings.h> #include <settings.h>
#include <trace.h> #include <trace.h>
#include <common/settings_objects.h> #include <common/settings_objects.h>
#include <common/common.h>
#include "resource.h"
#include <atomic> #include <atomic>
std::atomic<DWORD> g_dwModuleRefCount = 0; std::atomic<DWORD> g_dwModuleRefCount = 0;
@ -160,12 +161,13 @@ class PowerRenameModule : public PowertoyModuleIface
private: private:
// Enabled by default // Enabled by default
bool m_enabled = true; bool m_enabled = true;
std::wstring app_name;
public: public:
// Return the display name of the powertoy, this will be cached // Return the display name of the powertoy, this will be cached
virtual PCWSTR get_name() override virtual PCWSTR get_name() override
{ {
return L"PowerRename"; return app_name.c_str();
} }
// Enable the powertoy // Enable the powertoy
@ -203,25 +205,25 @@ public:
// Create a Settings object. // Create a Settings object.
PowerToysSettings::Settings settings(hinstance, get_name()); 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"); settings.set_icon_key(L"pt-power-rename");
// Link to the GitHub PowerRename sub-page // 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( settings.add_bool_toogle(
L"bool_persist_input", L"bool_persist_input",
L"Restore search, replace and flags values on launch from previous run.", GET_RESOURCE_STRING(IDS_RESTORE_SEARCH),
CSettings::GetPersistState()); CSettings::GetPersistState());
settings.add_bool_toogle( settings.add_bool_toogle(
L"bool_mru_enabled", 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()); CSettings::GetMRUEnabled());
settings.add_int_spinner( settings.add_int_spinner(
L"int_max_mru_size", 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(), CSettings::GetMaxMRUSize(),
0, 0,
20, 20,
@ -229,12 +231,12 @@ public:
settings.add_bool_toogle( settings.add_bool_toogle(
L"bool_show_icon_on_menu", L"bool_show_icon_on_menu",
L"Show icon on context menu.", GET_RESOURCE_STRING(IDS_ICON_CONTEXT_MENU),
CSettings::GetShowIconOnMenu()); CSettings::GetShowIconOnMenu());
settings.add_bool_toogle( settings.add_bool_toogle(
L"bool_show_extended_menu", 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()); CSettings::GetExtendedContextMenuOnly());
return settings.serialize_to_buffer(buffer, buffer_size); return settings.serialize_to_buffer(buffer, buffer_size);
@ -298,7 +300,10 @@ public:
PowerRenameModule() PowerRenameModule()
{ {
init_settings(); init_settings();
app_name = GET_RESOURCE_STRING(IDS_POWERRENAME);
} }
~PowerRenameModule(){};
}; };
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@ -1,13 +1,22 @@
#define IDS_POWERRENAME 801 #define IDS_POWERRENAME 801
#define IDI_RENAME 132 #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 // Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View File

@ -1,4 +1,3 @@
#include "stdafx.h" #include "stdafx.h"
#include <commctrl.h> #include <commctrl.h>
#include "Settings.h" #include "Settings.h"

View File

@ -8,6 +8,7 @@
#include <PowerRenameUI.h> #include <PowerRenameUI.h>
#include <PowerRenameManager.h> #include <PowerRenameManager.h>
#include <Shobjidl.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='*'\"") #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")