Localize "Restore recent close file" command

Close #5557, fix #1476, fix #5137, fix #5672
This commit is contained in:
Rajendra Singh 2019-04-21 19:31:10 +05:30 committed by Don HO
parent 401dbbc7d5
commit e9277deaa6
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -565,6 +565,14 @@ LRESULT Notepad_plus::init(HWND hwnd)
::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND);
csc.setName(purgeMenuItemString(menuName, true).c_str());
}
else
{
// The menu name is already present (e.g. "Restore recent close file")
// Now get the localized name if possible
generic_string localizedMenuName = _nativeLangSpeaker.getNativeLangMenuString(csc.getID());
if(!localizedMenuName.empty())
csc.setName(purgeMenuItemString(localizedMenuName.c_str(), true).c_str());
}
}
//Translate non-menu shortcuts
_nativeLangSpeaker.changeShortcutLang();
@ -5698,8 +5706,18 @@ bool Notepad_plus::reloadLang()
for (size_t i = 0; i < len; ++i)
{
CommandShortcut & csc = shortcuts[i];
::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND);
csc.setName(purgeMenuItemString(menuName, true).c_str());
// If menu item is not present (e.g. "Restore recent close file" might not present initially)
// then fill the localized string directly
if (::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND))
{
csc.setName(purgeMenuItemString(menuName, true).c_str());
}
else
{
generic_string localizedMenuName = _nativeLangSpeaker.getNativeLangMenuString(csc.getID());
if (!localizedMenuName.empty())
csc.setName(purgeMenuItemString(localizedMenuName.c_str(), true).c_str());
}
}
_accelerator.updateFullMenu();