Make tray icon context menu translatable

Fix #11628, close #13241
This commit is contained in:
ArkadiuszMichalski 2023-02-25 20:30:54 +01:00 committed by Don Ho
parent b8291d4911
commit 52d3c36e35
5 changed files with 64 additions and 23 deletions

View File

@ -385,8 +385,6 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="11009" name="Size Larger to Smaller"/>
</Commands>
</Main>
<Splitter>
</Splitter>
<TabBar>
<Item CMDID="41003" name="Close"/>
<Item CMDID="0" name="Close Multiple Tabs"/>
@ -424,6 +422,14 @@ The comments are here for explanation, it's not necessary to translate them.
<Item CMDID="44115" name="Apply Color 5"/>
<Item CMDID="44110" name="Remove Color"/>
</TabBar>
<TrayIcon>
<Item id="43101" name="Activate"/>
<Item id="43102" name="New"/>
<Item id="43103" name="New and Paste"/>
<Item id="43104" name="Open..."/>
<Item id="43013" name="Find in Files..."/>
<Item id="43105" name="Close Tray Icon"/>
</TrayIcon>
</Menu>
<Dialog>

View File

@ -385,8 +385,6 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="11009" name="Size Larger to Smaller"/>
</Commands>
</Main>
<Splitter>
</Splitter>
<TabBar>
<Item CMDID="41003" name="Close"/>
<Item CMDID="0" name="Close Multiple Tabs"/>
@ -424,6 +422,14 @@ The comments are here for explanation, it's not necessary to translate them.
<Item CMDID="44115" name="Apply Color 5"/>
<Item CMDID="44110" name="Remove Color"/>
</TabBar>
<TrayIcon>
<Item id="43101" name="Activate"/>
<Item id="43102" name="New"/>
<Item id="43103" name="New and Paste"/>
<Item id="43104" name="Open..."/>
<Item id="43013" name="Find in Files..."/>
<Item id="43105" name="Close Tray Icon"/>
</TrayIcon>
</Menu>
<Dialog>

View File

@ -2597,6 +2597,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
HMENU hTrayIconMenu; // shortcut menu
hmenu = ::LoadMenu(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDR_SYSTRAYPOPUP_MENU));
hTrayIconMenu = ::GetSubMenu(hmenu, 0);
_nativeLangSpeaker.changeLangTrayIconContexMenu(hTrayIconMenu);
SetForegroundWindow(hwnd);
TrackPopupMenu(hTrayIconMenu, TPM_LEFTALIGN, p.x, p.y, 0, hwnd, NULL);
PostMessage(hwnd, WM_NULL, 0, 0);

View File

@ -489,6 +489,33 @@ void NativeLangSpeaker::changeLangTabDropContextMenu(HMENU hCM)
}
}
void NativeLangSpeaker::changeLangTrayIconContexMenu(HMENU hCM)
{
if (!_nativeLangA) return;
TiXmlNodeA *tryIconMenu = _nativeLangA->FirstChild("Menu");
if (!tryIconMenu) return;
tryIconMenu = tryIconMenu->FirstChild("TrayIcon");
if (!tryIconMenu) return;
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
for (TiXmlNodeA *childNode = tryIconMenu->FirstChildElement("Item");
childNode ;
childNode = childNode->NextSibling("Item") )
{
TiXmlElementA *element = childNode->ToElement();
int id;
const char *sentinel = element->Attribute("id", &id);
const char *name = element->Attribute("name");
if (sentinel && (name && name[0]))
{
const wchar_t *nameW = wmc.char2wchar(name, _nativeLangEncoding);
::ModifyMenu(hCM, id, MF_BYCOMMAND, id, nameW);
}
}
}
void NativeLangSpeaker::changeConfigLang(HWND hDlg)
{

View File

@ -45,6 +45,7 @@ public:
TiXmlNodeA * searchDlgNode(TiXmlNodeA *node, const char *dlgTagName);
bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL, size_t titleMaxSize = 0);
void changeLangTabDropContextMenu(HMENU hCM);
void changeLangTrayIconContexMenu(HMENU hCM);
generic_string getSubMenuEntryName(const char *nodeName) const;
generic_string getNativeLangMenuString(int itemID) const;
generic_string getShortcutNameString(int itemID) const;