Fix handling of underscores in <item> tags in "wxrc -g" output
Unlike all the other nodes containing translatable text, the contents of the <item> tags, used for wxChoice, wxListBox etc items, is not escaped (because it can't contain mnemonics), so don't unescape it when outputting it from "wxrc --gettext" neither. See #18033.
This commit is contained in:
parent
6bd8cb964b
commit
689704119a
@ -949,6 +949,46 @@ static wxString ConvertText(const wxString& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum ContentsKind
|
||||||
|
{
|
||||||
|
Contents_NotTrans, // Not a translatable text at all.
|
||||||
|
Contents_TransOnly, // Translatable but not escaped text.
|
||||||
|
Contents_Text // Text, i.e. both translatable and escaped.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if the given node contains translatable text and, if it does, whether
|
||||||
|
// it's escaped (i.e. parsed using GetText()) or not.
|
||||||
|
ContentsKind
|
||||||
|
GetNodeContentsKind(wxXmlNode& node, const wxString& contents)
|
||||||
|
{
|
||||||
|
if ( node.GetName() == wxT("label") ||
|
||||||
|
(node.GetName() == wxT("value") && !contents.IsNumber()) ||
|
||||||
|
node.GetName() == wxT("help") ||
|
||||||
|
node.GetName() == wxT("hint") ||
|
||||||
|
node.GetName() == wxT("longhelp") ||
|
||||||
|
node.GetName() == wxT("tooltip") ||
|
||||||
|
node.GetName() == wxT("htmlcode") ||
|
||||||
|
node.GetName() == wxT("title") ||
|
||||||
|
node.GetName() == wxT("message") ||
|
||||||
|
node.GetName() == wxT("note") ||
|
||||||
|
node.GetName() == wxT("defaultdirectory") ||
|
||||||
|
node.GetName() == wxT("defaultfilename") ||
|
||||||
|
node.GetName() == wxT("defaultfolder") ||
|
||||||
|
node.GetName() == wxT("filter") ||
|
||||||
|
node.GetName() == wxT("caption") )
|
||||||
|
{
|
||||||
|
return Contents_Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This one is special: it is translated in XRC, but its contents is not
|
||||||
|
// escaped.
|
||||||
|
if ( node.GetName() == wxT("item") )
|
||||||
|
return Contents_TransOnly;
|
||||||
|
|
||||||
|
return Contents_NotTrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtractedStrings
|
ExtractedStrings
|
||||||
XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node)
|
XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node)
|
||||||
{
|
{
|
||||||
@ -963,41 +1003,26 @@ XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node)
|
|||||||
if ((node->GetType() == wxXML_ELEMENT_NODE) &&
|
if ((node->GetType() == wxXML_ELEMENT_NODE) &&
|
||||||
// parent is an element, i.e. has subnodes...
|
// parent is an element, i.e. has subnodes...
|
||||||
(n->GetType() == wxXML_TEXT_NODE ||
|
(n->GetType() == wxXML_TEXT_NODE ||
|
||||||
n->GetType() == wxXML_CDATA_SECTION_NODE) &&
|
n->GetType() == wxXML_CDATA_SECTION_NODE))
|
||||||
// ...it is textnode...
|
// ...it is textnode...
|
||||||
(
|
|
||||||
node/*not n!*/->GetName() == wxT("label") ||
|
|
||||||
(node/*not n!*/->GetName() == wxT("value") &&
|
|
||||||
!n->GetContent().IsNumber()) ||
|
|
||||||
node/*not n!*/->GetName() == wxT("help") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("hint") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("longhelp") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("tooltip") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("htmlcode") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("title") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("item") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("message") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("note") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("defaultdirectory") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("defaultfilename") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("defaultfolder") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("filter") ||
|
|
||||||
node/*not n!*/->GetName() == wxT("caption")
|
|
||||||
))
|
|
||||||
// ...and known to contain translatable string
|
|
||||||
{
|
{
|
||||||
if (!flagGettext ||
|
wxString s = n->GetContent();
|
||||||
node->GetAttribute(wxT("translate"), wxT("1")) != wxT("0"))
|
switch ( GetNodeContentsKind(*node, s) )
|
||||||
{
|
{
|
||||||
arr.push_back
|
case Contents_NotTrans:
|
||||||
(
|
break;
|
||||||
ExtractedString
|
|
||||||
(
|
case Contents_Text:
|
||||||
ConvertText(n->GetContent()),
|
s = ConvertText(s);
|
||||||
filename,
|
wxFALLTHROUGH;
|
||||||
n->GetLineNumber()
|
|
||||||
)
|
case Contents_TransOnly:
|
||||||
);
|
if (!flagGettext ||
|
||||||
|
node->GetAttribute(wxT("translate"), wxT("1")) != wxT("0"))
|
||||||
|
{
|
||||||
|
arr.push_back(ExtractedString(s, filename, n->GetLineNumber()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user