From 4509ef837d32ec67277cbd381fcc81c8db26465f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 25 Nov 2014 19:05:04 +0000 Subject: [PATCH] Translate menu accelerators from XRC The content of property was taken verbatim and appended to the (translated) label; this bypassed wx's internal accelerators translation mechanism, because wxMenuItem code quite reasonably assumes that the string passed to it is translated. Explicitly use SetAccel() instead, to force translation. This matters for languages such as German where e.g. Ctrl+ is translated as Strg+. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/xrc/xh_menu.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/xrc/xh_menu.cpp b/src/xrc/xh_menu.cpp index 0865063dcb..aaf45771b4 100644 --- a/src/xrc/xh_menu.cpp +++ b/src/xrc/xh_menu.cpp @@ -79,9 +79,6 @@ wxObject *wxMenuXmlHandler::DoCreateResource() int id = GetID(); wxString label = GetText(wxT("label")); wxString accel = GetText(wxT("accel"), false); - wxString fullLabel = label; - if (!accel.empty()) - fullLabel << wxT("\t") << accel; wxItemKind kind = wxITEM_NORMAL; if (GetBool(wxT("radio"))) @@ -100,8 +97,16 @@ wxObject *wxMenuXmlHandler::DoCreateResource() kind = wxITEM_CHECK; } - wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel, + wxMenuItem *mitem = new wxMenuItem(p_menu, id, label, GetText(wxT("help")), kind); + if (!accel.empty()) + { + wxAcceleratorEntry *entry = new wxAcceleratorEntry(); + if (entry->FromString(accel)) + mitem->SetAccel(entry); + else + delete entry; + } #if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN if (HasParam(wxT("bitmap")))