Author Topic: XML based compilers  (Read 96712 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #195 on: October 28, 2013, 01:26:27 pm »
I tried your patch but I obtain a compilation error : [...]
I wonder why it worked for me then...
Try this:
Code: [Select]
Index: src/plugins/compilergcc/compilerXML.cpp
===================================================================
--- src/plugins/compilergcc/compilerXML.cpp (revision 9423)
+++ src/plugins/compilergcc/compilerXML.cpp (working copy)
@@ -15,7 +15,7 @@
 #include "compilerXML.h"
 
 CompilerXML::CompilerXML(const wxString& name, const wxString& ID, const wxString& file)
-    : Compiler(name, ID), m_fileName(file)
+    : Compiler(wxGetTranslation(name), ID), m_fileName(file)
 {
     wxXmlDocument compiler;
     compiler.Load(m_fileName);
Index: src/sdk/compiler.cpp
===================================================================
--- src/sdk/compiler.cpp (revision 9423)
+++ src/sdk/compiler.cpp (working copy)
@@ -963,12 +963,12 @@
             wxString exclusive;
             if (!node->GetAttribute(wxT("exclusive"), &exclusive))
                 exclusive = (exclu ? wxT("true") : wxT("false"));
-            m_Options.AddOption(node->GetAttribute(wxT("name"), wxEmptyString),
+            m_Options.AddOption(wxGetTranslation(node->GetAttribute(wxT("name"), wxEmptyString)),
                                 node->GetAttribute(wxT("option"), wxEmptyString),
-                                category,
+                                wxGetTranslation(category),
                                 node->GetAttribute(wxT("additionalLibs"), wxEmptyString),
                                 node->GetAttribute(wxT("checkAgainst"), wxEmptyString),
-                                node->GetAttribute(wxT("checkMessage"), wxEmptyString),
+                                wxGetTranslation(node->GetAttribute(wxT("checkMessage"), wxEmptyString)),
                                 node->GetAttribute(wxT("supersedes"), wxEmptyString),
                                 exclusive == wxT("true"));
         }
@@ -1121,7 +1121,7 @@
             else if (tp == wxT("info"))
                 clt = cltInfo;
             wxArrayString msg = GetArrayFromString(node->GetAttribute(wxT("msg"), wxEmptyString) + wxT(";0;0"));
-            m_RegExes.Add(RegExStruct(node->GetAttribute(wxT("name"), wxEmptyString), clt,
+            m_RegExes.Add(RegExStruct(wxGetTranslation(node->GetAttribute(wxT("name"), wxEmptyString)), clt,
                                       node->GetNodeContent().Trim().Trim(false), wxAtoi(msg[0]),
                                       wxAtoi(node->GetAttribute(wxT("file"), wxT("0"))),
                                       wxAtoi(node->GetAttribute(wxT("line"), wxT("0"))),

Offline gd_on

  • Regular
  • ***
  • Posts: 374
Re: XML based compilers
« Reply #196 on: October 28, 2013, 02:19:53 pm »
With this last patch, it works  ;) (at least on the string I mentioned in my previous post).
Now, my job is : extract all "name" strings from .xml file and add them in my .po file.
Thanks

gd_on
Windows 10, svn C::B self generated (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits version (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1300
Re: XML based compilers
« Reply #197 on: October 28, 2013, 06:58:56 pm »
This is OT but anyway:
Do you really think localizating the compiler flags is a good idea? I mean, if you learn c/c++ or programming in general, you will be forced to learn and use english. If now a noob, who want learn to code, uses a localized IDE (only the compiler flags here) needs help, he will find it with more difficulties, because of the localization. GCC introduced localization a few releases back. I used it 2 times, and tried then to remove it, because i didn't could find any help in my language...
In short: Is compiler specific translation a goof idea?

greetings

Offline gd_on

  • Regular
  • ***
  • Posts: 374
Re: XML based compilers
« Reply #198 on: October 28, 2013, 07:43:18 pm »
This is the text accompanying and explaining the flag which is translated, not the flag itself!
So, I think that translating this text may help, a noob or a standard (experienced) user.
Myself, when I doubt on a translation (even on mine  :o), I revert C::B to English, and can see the "official" meaning. Just one or two click and a C::B restart !
I know that many people prefer to use C::B in English and not in their native language. This is their choice.
Myself, I generally prefer to see most of the interface in French, even if in English I understand generally. This is my choice, because I'm more comfortable then.
Both choices have their advantages and disadvantages.

So, yes I like a localized IDE ;). And you are not obliged to use it.

gd_on
« Last Edit: October 30, 2013, 10:57:27 am by gd_on »
Windows 10, svn C::B self generated (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits version (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #199 on: October 30, 2013, 01:03:02 am »
With this last patch, it works  ;) (at least on the string I mentioned in my previous post).
Okay, I will commit soon, if no further problems are identified.

Now, my job is : extract all "name" strings from .xml file and add them in my .po file.
Maybe a script could extract the strings?  It would likely be easier in the long run, for when the .xml files are updated.

Offline gd_on

  • Regular
  • ***
  • Posts: 374
Re: XML based compilers
« Reply #200 on: October 30, 2013, 10:55:20 am »
Quote
Maybe a script could extract the strings? 
It's exactly what I do. I have updated my extracting tool and testing it.
The previous version can be found in the forum (links in Code::Blocks' translation posts).
I have added those lines,
Code: [Select]
echo ""
echo "************************************************"
echo "* extracting strings from .xml compilers files *"
echo "************************************************"
echo ""
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "CodeBlocks_compiler name" > src_xml.cpp 2>> log.txt
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "Option name" >>  src_xml.cpp 2>> log.txt
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "checkMessage" >> src_xml.cpp 2>> log.txt
grep -v mabi src_xml.cpp | grep -v mno | grep -v apcs | grep -v mtpcs | grep -v mshed | grep -v msoft | grep -v mhard | grep -v mfpe | grep -v msched | grep -v mlong | grep -v mpic | grep -v mcirrus | grep -v mcalle | grep -v mpoke | grep -v mwords > src_xml2.cpp
xgettext -a -o xml.pot src_xml2.cpp
find xml.pot >> files.txt
but I think it could be improved because it still extract some lines that do not need translation.

gd_on
Windows 10, svn C::B self generated (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits version (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #201 on: October 26, 2014, 09:13:04 pm »
An afterthought:

Looking back on this, I think I made a major design failure.  Moving default settings and flags to .xml I still believe was a good choice, however, as soon as I started trying to do things like <if platform="windows"> ... </if>, it became a hack on the purpose of XML.  Logic does not belong at all in a data file.  This should have been either left in code, or (better) migrated to a script.

I guess this is another item to add to my todo list, and a lesson on planning ahead  :-\ .