X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/824e8eaaccab583f121e05e03678b110588a48cd..932142005296b619b7eaf71de6c2e0fecae6d12d:/contrib/utils/wxrc/wxrc.cpp?ds=sidebyside diff --git a/contrib/utils/wxrc/wxrc.cpp b/contrib/utils/wxrc/wxrc.cpp index 9acaeef5e4..597fd09602 100644 --- a/contrib/utils/wxrc/wxrc.cpp +++ b/contrib/utils/wxrc/wxrc.cpp @@ -28,7 +28,6 @@ #include "wx/cmdline.h" #include "wx/xrc/xml.h" -#include "wx/xrc/xmlio.h" #include "wx/ffile.h" #include "wx/wfstream.h" @@ -67,7 +66,7 @@ private: wxArrayString FindStrings(); wxArrayString FindStrings(wxXmlNode *node); - bool flagVerbose, flagCPP, flagCompress, flagGettext; + bool flagVerbose, flagCPP, flagGettext; wxString parOutput, parFuncname, parOutputPath; wxArrayString parFiles; int retCode; @@ -86,8 +85,7 @@ int XmlResApp::OnRun() { wxCMD_LINE_SWITCH, "h", "help", "show help message" }, { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" }, { wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" }, - { wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" }, - { wxCMD_LINE_SWITCH, "g", "gettext", "output .po catalog (to stdout or file if -o used)" }, + { wxCMD_LINE_SWITCH, "g", "gettext", "output list of translatable strings (to stdout or file if -o used)" }, { wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" }, { wxCMD_LINE_OPTION, "o", "output", "output file [resource.xrs/cpp]" }, { wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of neccessary handlers to this file" }, @@ -104,8 +102,6 @@ int XmlResApp::OnRun() delete wxLog::SetActiveTarget(new wxLogStderr); #endif - wxXmlDocument::AddHandler(new wxXmlIOHandlerBinZ); - wxCmdLineParser parser(cmdLineDesc, argc, argv); switch (parser.Parse()) @@ -146,7 +142,6 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline) flagGettext = cmdline.Found("g"); flagVerbose = cmdline.Found("v"); flagCPP = cmdline.Found("c"); - flagCompress = flagCPP && !cmdline.Found("u"); if (!cmdline.Found("o", &parOutput)) { @@ -210,7 +205,7 @@ wxArrayString XmlResApp::PrepareTempFiles() FindFilesInXML(doc.GetRoot(), flist, path); - doc.Save(parOutputPath + "/" + name + ".xrc", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN); + doc.Save(parOutputPath + "/" + name + ".xrc"); flist.Add(name + ".xrc"); } @@ -233,7 +228,8 @@ void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxSt (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE) && // ...it is textnode... - (node/*not n!*/->GetName() == "bitmap")) + ((node/*not n!*/->GetName() == "bitmap") || + (node/*not n!*/->GetName() == "url"))) // ...and known to contain filename { wxString fullname; @@ -396,7 +392,7 @@ void " + parFuncname + "()\n\ name + ".xrc" + "\");\n"); } - file.Write("\n}\n"); + file.Write("}\n"); } @@ -412,7 +408,7 @@ void XmlResApp::OutputGettext() else fout.Open(parOutput, _T("wt")); for (size_t i = 0; i < str.GetCount(); i++) - fout.Write(_T("msgid \"") + str[i] + _T("\"\nmsgstr \"\"\n\n")); + fout.Write(_T("_(\"") + str[i] + _T("\")\n")); if (!parOutput) fout.Detach(); } @@ -444,6 +440,36 @@ wxArrayString XmlResApp::FindStrings() +static wxString ConvertText(const wxString& str) +{ + wxString str2; + const wxChar *dt; + + for (dt = str.c_str(); *dt; dt++) + { + if (*dt == wxT('_')) + { + if ( *(++dt) == wxT('_') ) + str2 << wxT('_'); + else + str2 << wxT('&') << *dt; + } + else + { + switch (*dt) + { + case wxT('\n') : str2 << wxT("\\n"); break; + case wxT('\t') : str2 << wxT("\\t"); break; + case wxT('\r') : str2 << wxT("\\r"); break; + default : str2 << *dt; break; + } + } + } + + return str2; +} + + wxArrayString XmlResApp::FindStrings(wxXmlNode *node) { wxArrayString arr; @@ -469,9 +495,9 @@ wxArrayString XmlResApp::FindStrings(wxXmlNode *node) node/*not n!*/->GetName() == _T("htmlcode") || node/*not n!*/->GetName() == _T("title") )) - // ...and known to contain filename + // ...and known to contain translatable string { - arr.Add(n->GetContent()); + arr.Add(ConvertText(n->GetContent())); } // subnodes: