Author Topic: Patches for codeblocks about internationalization  (Read 21745 times)

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Patches for codeblocks about internationalization
« on: August 11, 2005, 07:57:27 am »
I have done something about codeblocks's internationalization, and it seems working for me. I have tested in WinXP SP1a, wxWindows 2.4.2, MingW GCC3.4.4 and CodeBlocks CVS in 11 Aug 2005. Details about the patches can be seen below:

Code
Index: src/CodeBlocks.cbp
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/CodeBlocks.cbp,v
retrieving revision 1.67.2.4
diff -u -r1.67.2.4 CodeBlocks.cbp
--- src/CodeBlocks.cbp 1 Aug 2005 09:45:40 -0000 1.67.2.4
+++ src/CodeBlocks.cbp 11 Aug 2005 05:13:24 -0000
@@ -334,7 +334,10 @@
  <Option includeInTargetAll="0"/>
  <Option projectResourceIncludeDirsRelation="4"/>
  <ExtraCommands>
- <Add before="update.bat"/>
+ <Add before="intl.bat"/>
+ </ExtraCommands>
+ <ExtraCommands>
+ <Add after="update.bat"/>
  </ExtraCommands>
  </Target>
  <Target title="console_runner">
Index: src/update.bat
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/update.bat,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 update.bat
--- src/update.bat 1 Aug 2005 04:41:07 -0000 1.13.2.1
+++ src/update.bat 11 Aug 2005 05:05:44 -0000
@@ -3,6 +3,7 @@
 
 if not exist output md output
 if not exist output\share md output\share
+if not exist output\share\locale md output\share\locale
 if not exist output\share\CodeBlocks md output\share\CodeBlocks
 if not exist output\share\CodeBlocks\lexers md output\share\CodeBlocks\lexers
 if not exist output\share\CodeBlocks\images md output\share\CodeBlocks\images
@@ -13,6 +14,10 @@
 set ZIPCMD=zip
 set RESDIR=devel\share\CodeBlocks
 
+set LOCALEDIR=output\share\locale
+
+call copymo
+
 echo Packing core UI resources
 %ZIPCMD% -j9 %RESDIR%\resources.zip src\resources\*.xrc > nul
 %ZIPCMD% -j9 %RESDIR%\manager_resources.zip sdk\resources\*.xrc > nul
Index: src/setup/CodeBlocks_Core.iss
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/setup/CodeBlocks_Core.iss,v
retrieving revision 1.16.2.4
diff -u -r1.16.2.4 CodeBlocks_Core.iss
--- src/setup/CodeBlocks_Core.iss 2 Aug 2005 19:12:12 -0000 1.16.2.4
+++ src/setup/CodeBlocks_Core.iss 11 Aug 2005 05:08:18 -0000
@@ -66,7 +66,6 @@
 Source: ..\output\share\CodeBlocks\manager_resources.zip; DestDir: {app}\share\CodeBlocks; Components: ProgramFiles
 Source: ..\output\share\CodeBlocks\plugin_wizard.zip; DestDir: {app}\share\CodeBlocks; Components: Plugins/PluginWizard
 Source: ..\output\share\CodeBlocks\todo.zip; DestDir: {app}\share\CodeBlocks; Components: Plugins/ToDo
-Source: ..\output\share\CodeBlocks\devpakupdater.zip; DestDir: {app}\share\CodeBlocks; Components: Plugins/DevPak
 Source: ..\output\share\CodeBlocks\plugins\astyle.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/AStyleFormatter
 Source: ..\output\share\CodeBlocks\plugins\classwizard.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/ClassWizard
 Source: ..\output\share\CodeBlocks\plugins\codecompletion.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/CodeCompletion
@@ -76,7 +75,6 @@
 Source: ..\output\share\CodeBlocks\plugins\pluginwizard.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/PluginWizard
 Source: ..\output\share\CodeBlocks\plugins\xpmanifest.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/XPManifest
 Source: ..\output\share\CodeBlocks\plugins\todo.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/ToDo
-Source: ..\output\share\CodeBlocks\plugins\devpakupdater.dll; DestDir: {app}\share\CodeBlocks\plugins; Components: Plugins/DevPak
 Source: ..\output\share\CodeBlocks\images\ascii.png; DestDir: {app}\share\CodeBlocks\images; Components: ProgramFiles
 Source: ..\output\share\CodeBlocks\images\codeblocks.png; DestDir: {app}\share\CodeBlocks\images; Components: ProgramFiles
 Source: ..\output\share\CodeBlocks\images\compile.png; DestDir: {app}\share\CodeBlocks\images; Components: ProgramFiles
@@ -190,6 +188,8 @@
 Source: ..\sdk\resources\lexers\lexer_rc.xml; DestDir: {app}\share\CodeBlocks\lexers; Components: ProgramFiles
 Source: ..\sdk\resources\lexers\lexer_xml.sample; DestDir: {app}\share\CodeBlocks\lexers; Components: ProgramFiles
 Source: ..\sdk\resources\lexers\lexer_xml.xml; DestDir: {app}\share\CodeBlocks\lexers; Components: ProgramFiles
+Source: ..\devel\share\locale\zh_CN\codeblocks.mo; DestDir: {app}\share\locale\zh_CN; Components: " Language"
+Source: ..\devel\share\locale\locale.alias; DestDir: {app}\share\locale\; Components: " Language"
 
 [Icons]
 Name: {group}\CodeBlocks; Filename: {app}\codeblocks.exe; IconIndex: 0; WorkingDir: {app}; Comment: Code::Blocks IDE; Components: ProgramFiles
@@ -225,6 +225,7 @@
 Name: Plugins/AStyleFormatter; Description: Astyle code formatter plugin; Types: custom full
 Name: Plugins/DefMimeHandler; Description: Default MIME handler; Types: custom compact full
 Name: Plugins/DevPak; Description: DevPaks support plugin; Types: custom
+Name: Language; Description: Language Packages; Types: custom full
 
 [UninstallRun]
-Filename: {app}\codeblocks.exe; Parameters: --clear-configuration; WorkingDir: {app}
+Filename: {app}\codeblocks.exe; Parameters: --clear-configuration; WorkingDir: {app}
\ No newline at end of file
Index: src/src/app.cpp
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/src/app.cpp,v
retrieving revision 1.37.2.5
diff -u -r1.37.2.5 app.cpp
--- src/src/app.cpp 7 Aug 2005 15:56:34 -0000 1.37.2.5
+++ src/src/app.cpp 11 Aug 2005 01:07:56 -0000
@@ -173,7 +173,7 @@
 
 void CodeBlocksApp::InitFrame()
 {
-    MainFrame *frame = new MainFrame((wxFrame*)0L);
+    MainFrame *frame = new MainFrame(m_locale, (wxFrame*)0L);
     #ifdef __WXMSW__
         if(g_DDEServer)
             g_DDEServer->SetFrame(frame);
@@ -221,6 +221,34 @@
 
     if(!LoadConfig())
         return false;
+
+    const wxString langs[] =
+    {
+        _T("(System default)"),
+        _T("Chinese"),
+        _T("English"),
+        _T("English (U.S.)")
+//        _T("German"),
+//        _T("Russian"),
+    };     
+    int lng =-1;
+    lng = wxGetSingleChoiceIndex(_T("Please choose language:"), _T("Language"),
+                                   WXSIZEOF(langs), langs);   
+    switch (lng)
+    {
+        case 0 : m_locale.Init(wxLANGUAGE_DEFAULT); break;
+        case 1 : m_locale.Init(wxLANGUAGE_CHINESE_SIMPLIFIED); break;
+        case 2: m_locale.Init(wxLANGUAGE_ENGLISH); break;
+        case -1:
+        case 3 : m_locale.Init(wxLANGUAGE_ENGLISH_US); break;
+//        case 4 : m_locale.Init(wxLANGUAGE_GERMAN); break;
+//        case 5 : m_locale.Init(wxLANGUAGE_RUSSIAN); break;       
+    }
+    wxLocale::AddCatalogLookupPathPrefix(wxT("./share/locale"));
+    wxLocale::AddCatalogLookupPathPrefix(wxT("."));
+    wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
+    m_locale.AddCatalog(wxT("codeblocks"));
+
 
  m_pSingleInstance = 0;
     if (ConfigManager::Get()->Read(_T("/environment/single_instance"), 1))
Index: src/src/app.h
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/src/app.h,v
retrieving revision 1.9
diff -u -r1.9 app.h
--- src/src/app.h 17 Jun 2005 08:07:48 -0000 1.9
+++ src/src/app.h 11 Aug 2005 00:44:48 -0000
@@ -11,7 +11,8 @@
 @remarks VC++ 6 requires the following headers to compile correctly, so I added a check for it
 */
 #if !defined(WX_PRECOMP) || defined(_MSC_VER)
-    #include <wx/wx.h>
+    #include <wx/wx.h>
+    #include <wx/intl.h>
     #include <wx/laywin.h>
     #include <wx/image.h>
     #include <wx/filename.h>
@@ -58,7 +59,8 @@
         void ClearConf();
         bool InitXRCStuff();
         void InitFrame();
-        void CheckVersion();
+        void CheckVersion();
+        wxLocale m_locale; // locale we'll be using
     private:
         void ShowSplashScreen();
         void HideSplashScreen();
Index: src/src/main.cpp
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/src/main.cpp,v
retrieving revision 1.78.2.8
diff -u -r1.78.2.8 main.cpp
--- src/src/main.cpp 8 Aug 2005 21:56:26 -0000 1.78.2.8
+++ src/src/main.cpp 11 Aug 2005 02:26:36 -0000
@@ -323,9 +323,10 @@
 
 END_EVENT_TABLE()
 
-MainFrame::MainFrame(wxWindow* parent)
+MainFrame::MainFrame(wxLocale& lang, wxWindow* parent)
        : wxFrame(parent, -1, _T("MainWin"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE),
-    m_pAccel(0L),
+    m_pAccel(0L),
+    m_locale(lang),
     m_pCloseFullScreenBtn(0L),
        m_pNotebook(0L),
     m_pLeftSash(0L),
@@ -1032,15 +1033,15 @@
 {
     wxCommandEvent evt;
     wxString link = event.GetString();
-    if (link.Matches(_("CB_CMD_NEW_PROJECT")))
+    if (link.Matches(_T("CB_CMD_NEW_PROJECT")))
         TemplateManager::Get()->NewProject();
-    else if (link.Matches(_("CB_CMD_OPEN_PROJECT")))
+    else if (link.Matches(_T("CB_CMD_OPEN_PROJECT")))
         OnFileOpen(evt);
-    else if (link.Matches(_("CB_CMD_CONF_ENVIRONMENT")))
+    else if (link.Matches(_T("CB_CMD_CONF_ENVIRONMENT")))
         OnSettingsEnvironment(evt);
-    else if (link.Matches(_("CB_CMD_CONF_EDITOR")))
+    else if (link.Matches(_T("CB_CMD_CONF_EDITOR")))
         Manager::Get()->GetEditorManager()->Configure();
-    else if (link.Matches(_("CB_CMD_CONF_COMPILER")))
+    else if (link.Matches(_T("CB_CMD_CONF_COMPILER")))
     {
         PluginsArray arr = Manager::Get()->GetPluginManager()->GetCompilerOffers();
         if (arr.GetCount() != 0)
Index: src/src/main.h
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/src/main.h,v
retrieving revision 1.27
diff -u -r1.27 main.h
--- src/src/main.h 1 Jul 2005 20:11:59 -0000 1.27
+++ src/src/main.h 11 Aug 2005 00:52:02 -0000
@@ -17,8 +17,10 @@
 {
     public:
         wxAcceleratorTable* m_pAccel;
-        MainFrame(wxWindow* parent = (wxWindow*)NULL);
+        MainFrame(wxLocale& m_locale, wxWindow* parent = (wxWindow*)NULL);
         ~MainFrame();
+
+        wxLocale& m_locale;
 
         bool Open(const wxString& filename, bool addToHistory = true);
         bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
--- src/copymo.bat
+++ src/copymo.bat
@@ -0,0 +1,13 @@
+echo Copying language files...
+
+if not exist %LOCALEDIR%\zh_CN md %LOCALEDIR%\zh_CN
+copy /y po\zh_CN.mo    %LOCALEDIR%\zh_CN\codeblocks.mo >nul
+
+rem if not exist %LOCALEDIR%\zh_TW md %LOCALEDIR%\zh_TW
+rem copy /y po\zh_TW.mo    %LOCALEDIR%\zh_TW\codeblocks.mo
+
+rem if not exist %LOCALEDIR%\fr md %LOCALEDIR%\fr
+rem copy /y po\fr.mo    %LOCALEDIR%\fr\codeblocks.mo
+
+rem if not exist %LOCALEDIR%\ru md %LOCALEDIR%\ru
+rem copy /y po\ru.mo    %LOCALEDIR%\ru\codeblocks.mo

--- src/intl.bat
+++ src/intl.bat
@@ -0,0 +1,26 @@
+@echo off
+wxrc src\resources\*.xrc -g -o  src\src-xrc.cpp
+wxrc sdk\resources\*.xrc -g -o  sdk\src-sdk.cpp
+xgettext -C -n -k_ -o po\codeblocks.pot src\*.cpp
+xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\*.cpp
+cd po
+if exist temp.po delete temp.po
+
+rename zh_CN.po temp.po
+msgmerge -o zh_CN.po temp.po codeblocks.pot
+del temp.po
+msgfmt -o zh_CN.mo zh_CN.po
+
+rem rename en.po temp.po
+rem msgmerge -o en.po temp.po codeblocks.pot
+rem del temp.po
+rem msgfmt -o en.mo en.po
+
+cd ..
+
+if not exist devel md devel
+if not exist devel\locale md devel\locale
+
+set LOCALEDIR=devel\share\locale
+
+call copymo


Yes, I have modified some files like main.cpp, main.h, app.cpp, app.h, CodeBlocks_Core.iss and update.bat. And I have added somefile like intl.bat, copymo.bat, codeblocks.pot and zh_CN.po.

The english po file is codeblocks.pot which can be translated into any other language. I have translated it into Chinese, so you can see the file  zh_CN.po.

I have place *.mo to codeblocks\share\locale\*.

In fact, there are so many works unfinished. For example, we should place a language choice to someplace like Settings\Environment. Hope somebody can do this work.  Many source files should be modified in order that we can get more information which should be translated.

Then I want to translate it into Chinese. You can see I have done something, although it is not enough  :lol:

========================

I have just update the patch file for codeblocks.pot containing strings in *.XRC .

It works well.

Needed tools are gettext and wxrc belong to wxWidgets



[attachment deleted by admin]
« Last Edit: August 12, 2005, 02:01:54 am by heromyth »

takeshimiya

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #1 on: August 11, 2005, 10:19:55 am »
Great!  :).

You'll want to translate XRC's also.

As poEdit/gettext can't get the strings from a .xrc file, you must extract first to a .h/.cpp
There's a tool to do that in %WXDIR%/utils/wxrc.
Then with wxrc you extract the strings from the XRC to be translated, and these strings are outputted to _() in a .h/.cpp

Hope that helps.

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #2 on: August 11, 2005, 05:23:50 pm »
Yes, there are so many text exist in XRC files. I have tried to translate them directly, but failed for that the tinyXML plugin seems it can't handle these translated files. Thanks takeshimiya for your advices. I'll try it. Because of this, I think I should spend more time to unstand how Code::Blocks  handles XRC files. After that, I'll try to translate these texts in XRC files.

Here are two attachs, one is an English po file in which all texts just are got from directory src and sdk,  and another is an Chinese po file I have translated.

==================
This time, I updated codeblocks.pot.txt because it now contains all strings in src\*.cpp, sdk\*.cpp, src\resources\*.xrc and sdk\resources\*.xrc.


[attachment deleted by admin]
« Last Edit: August 11, 2005, 06:52:29 pm by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #3 on: August 11, 2005, 05:31:28 pm »
Great!  :).

You'll want to translate XRC's also.

As poEdit/gettext can't get the strings from a .xrc file, you must extract first to a .h/.cpp
There's a tool to do that in %WXDIR%/utils/wxrc.
Then with wxrc you extract the strings from the XRC to be translated, and these strings are outputted to _() in a .h/.cpp

Hope that helps.

Suppose that I had got these strings and translated, how can I let  Code::Blocks find these translated strings? Should I add these .h/.cpp convered from XRC to  Code::Blocks project?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #4 on: August 11, 2005, 06:12:30 pm »
 :shock: i'm getting dizzy... i really don't know how this works.

Anyway, there are some parts of codeblocks where menus are added and searched, and these are searched by string. (And I thought unicode was difficult! :P ) Anyway, did you use the sources from VERSION_1_0 branch?

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #5 on: August 11, 2005, 07:05:07 pm »
:shock: i'm getting dizzy... i really don't know how this works.

It works because of  wxXRC_USE_LOCALE. XRC files can work together with gettext/wxLocale.

Quote
Anyway, there are some parts of codeblocks where menus are added and searched, and these are searched by string. (And I thought unicode was difficult! :P ) Anyway, did you use the sources from VERSION_1_0 branch?

Yes, the sources is from VERSION_1_0 branch. Just now, I have updated file codeblocks.pot which should contain mostly strings shown by Code::Blocks.
« Last Edit: August 11, 2005, 07:09:24 pm by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #6 on: August 12, 2005, 02:05:03 am »
Screenshots!

You can download the test program at http://bitworld.ys168.com.

[attachment deleted by admin]

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Patches for codeblocks about internationalization
« Reply #7 on: August 12, 2005, 03:03:32 am »
Even with Spanish being my first language I like to use Code::Blocks in English, but anyway, it's looking nice and I know people will like it.

It will also help Code::Blocks to spread even more :)

takeshimiya

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #8 on: August 12, 2005, 05:56:00 am »
Yes, specially with the users of another writting systems like the ones from China, Japan, etc.

My mother tonge is also Spanish, and I like to use all programs in English, so ie. when posting in a forum, you can refer to the English names of things.
It's not likely Yiannis or any non-Spanish parlant will understand what "compilar el código fuente del proyecto" means :wink:

I can, if anyone is interested, make the Spanish locale (I like to do translations because I work on a fansub) :D

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #9 on: August 12, 2005, 08:57:48 am »
It's not likely Yiannis or any non-Spanish parlant will understand what "compilar el código fuente del proyecto" means :wink:

"to compile the source code of the project"

So I used babelfish :lol:, but even before that I actually thought "compilar" would have to be something about compiler/compiling, "código" looks like code and "proyecto" is pretty obvious.

Oh, and my mother tongue is Dutch, but I definitely prefer my computer programs in English. Not just because it makes it easier when speaking about them in English, but also because Dutch translations of English stuff tend to suck ;). Especially computer-related English stuff.
That's also why I like the fact TV here is subtitled, by the way: I can just ignore the subtitles unless I couldn't hear some of it, or didn't understand a word. That way, I'm only subjected to lousy translations when I actually need a translation. (To be fair, the translations aren't usually terrible but sometimes it's painfully clear the translator didn't hear a sentence correctly or hasn't seen the show before in his life. Especially with scifi shows)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #10 on: August 12, 2005, 09:02:06 am »
(To be fair, the translations aren't usually terrible but sometimes it's painfully clear the translator didn't hear a sentence correctly or hasn't seen the show before in his life. Especially with scifi shows)

Lol! :lol: That reminded me of that spanish translation for Starwars:
"Me llamo Lucas Trota-cielos, y he venido a rescatarte!"
(My name is Lucas, the one who walks on the sky, and i've come to rescue you!) :lol:

(OK, sorry about the off-topic, but I just couldn't resist :oops: ). Anyway, let's see how to apply that intl stuff later.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Patches for codeblocks about internationalization
« Reply #11 on: August 12, 2005, 10:20:10 am »
Not just because it makes it easier when speaking about them in English, but also because Dutch translations of English stuff tend to suck ;). Especially computer-related English stuff.
Oh, if you think the Dutch ones suck, you haven't read the German ones... even if you know what it is supposed to be, you fail to understand them sometimes. First thing I usually do after installing a localized program is delete the locale folder. :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #12 on: August 12, 2005, 10:35:00 am »
Oh, if you think the Dutch ones suck, you haven't read the German ones... even if you know what it is supposed to be, you fail to understand them sometimes. First thing I usually do after installing a localized program is delete the locale folder. :)
Actually, I have :?. My father has some farms in Germany, and some German employees. They use computers, and I'm a computer geek. Germany has voice-overs on tv, so Germans hear less English. I was bad at German in school and dropped it possible. Do the math.

I've noticed some programs know I speak Dutch even though I have an English Windows version. I hate that "feature". If I forget to switch it to English, or more likely while trying to do so as the first thing after starting it for the first time ;), I usually have the problem of knowing what menu item I want, but having to figure out the translation. Often when I eventually figure it out I cringe.

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #13 on: August 13, 2005, 05:04:18 pm »
Now, I think I  have got almost all the strings that should be translated in Code::Blocks (You can download the english po file codeblocks.pot at http://bitworld.ys168.com). And I have finished translating them into Chinese.

However, I have confronted some strang problems during the process of translation. I can't translate these words belown:

Code
#: src\main.cpp:1057
#: src\main.cpp:1084
#: src\src-xrc.cpp:64
msgid "&File"
msgstr ""

#: src\src-xrc.cpp:97
#: sdk\sdk-xrc.cpp:10
#: sdk\sdk-xrc.cpp:26
#: sdk\sdk-xrc.cpp:199
#: plugins\compilergcc\compilergcc-xrc.cpp:163
msgid "&Edit"
msgstr ""

#: src\src-xrc.cpp:167
msgid "Sea&rch"
msgstr ""

#: src\src-xrc.cpp:178
msgid "&Project"
msgstr ""

#: sdk\cbeditor.cpp:1101
#: sdk\sdk-xrc.cpp:130
#: sdk\sdk-xrc.cpp:134
#: plugins\codecompletion\codecompletion.cpp:130
#: plugins\compilergcc\compilergcc-xrc.cpp:104
#: plugins\compilergcc\compilergcc-xrc.cpp:128
#: plugins\compilergcc\compilergcc-xrc.cpp:157
msgid "Edit"
msgstr ""

#: sdk\projectmanager.cpp:294
#: sdk\projectmanager.cpp:487
#: sdk\sdk-xrc.cpp:205
#: plugins\debuggergdb\debuggergdb.cpp:256
msgid "Project"
msgstr ""

#: plugins\compilergcc\compilergcc.cpp:947
#: plugins\debuggergdb\debuggergdb.cpp:413
msgid "project"
msgstr ""

#: sdk\projectmanager.cpp:281
#: plugins\codecompletion\codecompletion.cpp:140
msgid "Search"
msgstr ""

#: sdk\editormanager.cpp:220
#: sdk\projectmanager.cpp:286
#: plugins\compilergcc\compilergcc.cpp:243
#: plugins\debuggergdb\backtracedlg.cpp:42
#: plugins\todo\todolist.cpp:87
msgid "File"
msgstr ""

Not because they are too difficult to be translated, but because that once I have translated them, some of the sub-menu items will disappear. For example, I have just only translated "&Project". Now you can the result in the second attachment. The first attachement should be the correct. And you can see the third attachement which shows that I just leave  "&Project" untranslated. Of course, the third is also correct.

Another question is that I must treat '$$' as '$' when I translate. Otherwise, Code::Blocks can't get the translation of the string which is include '$$'.  For example the string '$$DIR' in File->Properties->dependencies, although it is not translated, it shows as these: '$DIR'. So when being translated, it should be treated as '$DIR'. Whose problem this is? Gettext? Or wxWidget? Or me?

Hope someone give me some advices. Thanks!

[attachment deleted by admin]
« Last Edit: August 14, 2005, 05:05:38 am by heromyth »

takeshimiya

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #14 on: August 13, 2005, 06:22:52 pm »
Not because they are too difficult to be translated, but because that once I have translated them, some of the sub-menu items will disappear. For example, I have just only translated "&Project". Now you can the result in attachment two. The attachemnt one should be the correct.

is because

Anyway, there are some parts of codeblocks where menus are added and searched, and these are searched by string.

Anyway it wouldn't be better to search for an ID of the menu instead of the string??

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #15 on: August 13, 2005, 06:41:18 pm »
argh

wxMenuBar::FindMenu
int FindMenu(const wxString& title) const

There's no FindMenu(int it) :( The reason is because wxMenu is a wxEvtHandler, not a wxWindow - and therefore, it has no associated Id. It has to be found by string :-(

Solutions anyone?

takeshimiya

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #16 on: August 13, 2005, 08:10:13 pm »
None of this helps?

Code
wxMenuItem * FindItem(int id, wxMenu **menu = NULL) const
Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to.
If menu is !NULL, it will be filled with wxMenu this item belongs to

Code
int FindItem(const wxString& itemString) const
Finds the menu item id for a menu item string.

Code
wxString GetTitle() const
Returns the title of the menu.

Code
wxString GetLabel(int id) const
Returns a menu item label.

Code
int GetMenuCount() const
Get the number of menus in the menu bar

Code
wxMenu *GetMenu(size_t pos) const
Get the menu at given position

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #17 on: August 13, 2005, 08:36:33 pm »
Now maybe I'm saying something stupid here, but wouldn't a quick fix be to just search for the translated string? Two translations of the same string should automatically be the same, right?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #18 on: August 14, 2005, 03:31:24 am »
Yes, but if the strings are translated the same... why didn't the menu creation work? (See previous screenshots).

Or you mean searching for the *untranslated* strings? ugh i think i got confused now.

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Ask: Why use '$$' instead of '$' in XRC Resource
« Reply #19 on: August 14, 2005, 07:49:04 am »
Suppose there has something like this:
   
Code
<label>$$compiler<label>
in a XRC file. When some programs use this XRC file to show the label, we can see this:
   
Code
$compiler

The '$$' has changed into '$'. If we change to:
   
Code
<label>$compiler<label>
Now we can see that:
   
Code
[u]c[/u]ompiler

What has happened. I have tried to look into the wxWidget manual, but got nothing.

Why I care about this. That's because I want to translate some strings in XRC files. I use utils\wxxrc.exe to get these strings. Only all the '$$'s were treated as '$'s while being translated,  my program could get the correct translations.

Maybe make wxxrc change '$$' into '$' while getting the strings, we could resolve this problem!?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #20 on: August 14, 2005, 10:56:27 am »
Hmmm perhaps it would be good to ask this question in the wxWidgets forums...

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #21 on: August 14, 2005, 11:03:06 am »
Yes, but if the strings are translated the same... why didn't the menu creation work? (See previous screenshots).

Or you mean searching for the *untranslated* strings? ugh i think i got confused now.

Oh sorry, I thought I recalled something from a Unicode thread where you mentioned something about not knowing whether to use _() or _T() when searching for menu options. I can't find it now. May have been my imagination.
Anyway, are you sure everywhere you search for menu options, they are translated when converting to Unicode (_(), not _T())?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #22 on: August 14, 2005, 11:07:22 am »
ACK. No, I can't remember.But those menus in particular were in the compilergcc.cpp. Altho I remember I didn't use _( in some other parts...

Luckily, we have multi-file search n replace in C::B :). The trick is knowing what string to search for... :oops:

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #23 on: August 15, 2005, 04:08:06 pm »
Hmmm perhaps it would be good to ask this question in the wxWidgets forums...

I have tested sample\xrc in wxWidget 2.6.1. There is no any problem. For example, I add then '$$' to some labels, and I can see '$$'. I add then '$' to some labels, and I can see '$'. Maybe, I should check the Code::Blocks' codes.

Now, I can sure this problem is because of Code::Blocks. Suppose we use some XRC tools like DialogBlocks to load Code::Blocks' XRC files like plugins\compilergcc\resources\advanced_compiler_options.xrc. We can see the result like the first attachemt. However, we get aonther result like the second attachment in Code::Blocks. I have checked the Code::Blocks' code, and found nothing.



[attachment deleted by admin]
« Last Edit: August 16, 2005, 04:13:28 am by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #24 on: August 16, 2005, 07:10:54 am »
Quote
I have tested sample\xrc in wxWidget 2.6.1. There is no any problem. For example, I add then '$$' to some labels, and I can see '$$'. I add then '$' to some labels, and I can see '$'. Maybe, I should check the Code::Blocks' codes.

Now, I can sure this problem is because of Code::Blocks. Suppose we use some XRC tools like DialogBlocks to load Code::Blocks' XRC files like plugins\compilergcc\resources\advanced_compiler_options.xrc. We can see the result like the first attachemt. However, we get aonther result like the second attachment in Code::Blocks. I have checked the Code::Blocks' code, and found nothing.

I think I have known the reasons. If I change the second line:
Code
<resource>
in all XRC files in Code::Blocks to :
Code
<resource version="2.3.0.1">

OK, all the '$$'s in labels will be shown as '$$'s, not as '$'s.

--------------------------------------------------

Here is a patch for utils\wxrc.

[attachment deleted by admin]
« Last Edit: August 16, 2005, 12:46:39 pm by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #25 on: August 17, 2005, 09:42:42 am »

However, I have confronted some strang problems during the process of translation. I can't translate these words belown:

Code
#: src\main.cpp:1057
#: src\main.cpp:1084
#: src\src-xrc.cpp:64
msgid "&File"
msgstr ""

Not because they are too difficult to be translated, but because that once I have translated them, some of the sub-menu items will disappear. For example, I have just only translated "&Project". Now you can the result in the second attachment. The first attachement should be the correct. And you can see the third attachement which shows that I just leave  "&Project" untranslated. Of course, the third is also correct.


All the problems have seemed to be fixed. See the first attachment. More details about the fixes can been seen in the second attachment. By now, I think using this patch can totally implement the  internationalization of Code::Blocks v1.0 (CVS with wxWidgets v2.4.2).


[attachment deleted by admin]
« Last Edit: August 17, 2005, 09:52:55 am by heromyth »

liweifuj

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #26 on: November 27, 2005, 11:16:34 am »
Hi Heromyth,

I am looking for a IDE because I have to work under Linux. Seen your production I am really getting exciting, because the English edition could not good support Chinese input, so can you switch a copy to me ? I use fctix as the Chinese input, but can not locate the character in the edit panel. My OS is FC4. Thanks.


David

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #27 on: November 29, 2005, 05:28:38 am »
Hi Heromyth,

I am looking for a IDE because I have to work under Linux. Seen your production I am really getting exciting, because the English edition could not good support Chinese input, so can you switch a copy to me ? I use fctix as the Chinese input, but can not locate the character in the edit panel. My OS is FC4. Thanks.


David

I just compiled under Windows OS, and haven't tested it under Linux. I'am planning to port it to FreeBSD. It seems to have been done by someone.
The CB in CVS now supports Language Choice perfectly. You must check it out and compile it youself. Here are my codes of InitLocale() in app.cpp


Code
void CodeBlocksApp::InitLocale()
{
    const wxString langs[] =
    {
        _T("(System default)"),
//        _T("English (U.S.)")
//        _T("English"),
        _T("Chinese (Simplified)"),
//        _T("German"),
//        _T("Russian"),
    };

    // Must have the same order than the above
    const long int locales[] =
    {
        wxLANGUAGE_DEFAULT,
//        wxLANGUAGE_ENGLISH_US,
//        wxLANGUAGE_ENGLISH,
        wxLANGUAGE_CHINESE_SIMPLIFIED,
//        wxLANGUAGE_GERMAN,
//        wxLANGUAGE_RUSSIAN
    };

    int lng = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/locale/language"),(int)-2);

    if(lng==-2) // -2 = Undefined / ask
    {
        lng = -1;
        if(WXSIZEOF(langs)>=2)
            lng = wxGetSingleChoiceIndex(_T("Please choose language:"), _T("Language"),
                                           WXSIZEOF(langs), langs);

        if(lng >= 0 && (unsigned)abs(lng) < (unsigned)WXSIZEOF(locales))
            lng = locales[lng];
        else
            lng = -1; // -1 = Don't use locale
    }

ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));
    if(lng>=0)
    {
        m_locale.Init(lng);
        wxLocale::AddCatalogLookupPathPrefix(ConfigManager::GetDataFolder() + _T("/locale"));
        wxLocale::AddCatalogLookupPathPrefix(wxT("."));
        wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
        m_locale.AddCatalog(wxT("codeblocks"));
        cfg->Write(_T("/locale/language"), (int)lng);
    }
    else
        Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/locale/language"),(int)-1);
}