Difference between revisions of "Internationalization"

From CodeBlocks
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Developer Documentation]]
 
[[Category:Developer Documentation]]
  
This article is about how to realize and use localized C:B. All the works have been done under Windows XP SP2.
+
This article is about how to realize and use localized C:B. Original article written by heromyth. Reviewed by gd_on.
  
 
== Get the English POT file ==
 
== Get the English POT file ==
Line 7: Line 7:
 
The url of the english POT file is at:
 
The url of the english POT file is at:
  
for the '''original site''' (but obsolete) : https://translations.launchpad.net/codeblocks/trunk/+pots/codeblocks
+
for the '''original site''' (''but obsolete'') : https://translations.launchpad.net/codeblocks/trunk/+pots/codeblocks
  
 
or
 
or
Line 21: Line 21:
 
or : http://forums.codeblocks.org/index.php/topic,1022.msg159075.html#msg159075
 
or : http://forums.codeblocks.org/index.php/topic,1022.msg159075.html#msg159075
 
   
 
   
Of course, you can run intl.bat to generate the POT file.
+
Of course, you can run extract.cmd to generate the POT file.
The tool wxrc.exe's url is http://www.dlang.net/dl/wxrc.exe.
+
This tool use several unix-like tools as find, rm, grep, xargs, xgettext, msgcat. Some of them are available with many MinGW distributions or Msys2.
  
The content of '''intl.bat''' is below:
+
'''Note''' : you '''must''' use the unix-like find.exe, ''not'' the Windows one : they have not the same syntax. So, the unix-like find.exe must be found in your PATH, before the Windows one!
  
rem ======= Begin of intl.bat =======
+
The tool wxrc.exe's url is http://www.dlang.net/dl/wxrc.exe (not sure it's sill available there). Or you can find the source in wxWidgets/utils and build it.
+
@echo off
+
wxrc src\resources\*.xrc -g -o  src\src-xrc.cpp
+
wxrc sdk\resources\*.xrc -g -o  sdk\sdk-xrc.cpp
+
wxrc plugins\astyle\resources\*.xrc -g -o  plugins\astyle\astyle-xrc.cpp
+
wxrc plugins\autosave\*.xrc -g -o  plugins\autosave\autosave-xrc.cpp
+
wxrc plugins\classwizard\resources\*.xrc -g -o  plugins\classwizard\classwizard-xrc.cpp
+
wxrc plugins\codecompletion\resources\*.xrc -g -o  plugins\codecompletion\codecompletion-xrc.cpp
+
wxrc plugins\compilergcc\resources\*.xrc -g -o  plugins\compilergcc\compilergcc-xrc.cpp
+
wxrc plugins\debuggergdb\resources\*.xrc -g -o  plugins\debuggergdb\debuggergdb-xrc.cpp
+
wxrc plugins\defaultmimehandler\resources\*.xrc -g -o  plugins\defaultmimehandler\defaultmimehandler-xrc.cpp
+
wxrc plugins\projectsimporter\resources\*.xrc -g -o  plugins\projectsimporter\projectsimporter-xrc.cpp
+
wxrc plugins\projectsimporter\resources\*.xrc -g -o  plugins\projectsimporter\projectsimporter-xrc.cpp
+
wxrc plugins\scriptedwizard\resources\plugins\*.xrc -g -o  plugins\scriptedwizard\resources\plugins\scriptedwizard-xrc.cpp
+
wxrc plugins\scriptedwizard\resources\wxwidgets\*.xrc -g -o  plugins\scriptedwizard\resources\wxwidgets\wxwidgets-xrc.cpp
+
wxrc plugins\todo\resources\*.xrc -g -o  plugins\todo\todo-xrc.cpp
+
if not exist po md po
+
xgettext -C -n -k_ -o po\codeblocks.pot include\*.h
+
xgettext -C -n -k_ -j --from-code=UTF-8 -o po\codeblocks.pot src\*.cpp src\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\*.cpp
+
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\scripting\bindings\*.cpp include\scripting\bindings\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\astyle\*.cpp plugins\astyle\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\astyle\astyle\*.cpp plugins\astyle\astyle\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\autosave\*.cpp plugins\autosave\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\classwizard\*.cpp plugins\classwizard\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\codecompletion\*.cpp plugins\codecompletion\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\codecompletion\parser\*.cpp plugins\codecompletion\parser\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\compilergcc\*.cpp plugins\compilergcc\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\debuggergdb\*.cpp plugins\debuggergdb\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\defaultmimehandler\*.cpp plugins\defaultmimehandler\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\headerguard\*.cpp plugins\headerguard\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\loghacker\*.cpp plugins\loghacker\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\modpoller\*.cpp plugins\modpoller\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\openfileslist\*.cpp plugins\openfileslist\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\projectsimporter\*.cpp plugins\projectsimporter\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\scriptedwizard\*.cpp plugins\scriptedwizard\*.h plugins\scriptedwizard\resources\*.script
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\scriptedwizard\resources\plugins\templates\*.cpp plugins\scriptedwizard\resources\plugins\templates\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\scriptedwizard\resources\wxwidgets\common\*.cpp plugins\scriptedwizard\resources\wxwidgets\common\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\tidycmt\*.cpp plugins\tidycmt\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\todo\*.cpp plugins\todo\*.h
+
xgettext -C -n -k_ -j -o po\codeblocks.pot plugins\xpmanifest\*.cpp plugins\xpmanifest\*.h
+
pause
+
rem ======= End of intl.bat =======
+
  
The content of '''intl-plugin.bat''' is below:
+
The content of '''extract.cmd''' is below:
  
  rem ======= Begin of intl-plugin.bat =======
+
  rem ======= Begin of extract.cmd =======
 
   
 
   
 
  @echo off
 
  @echo off
  wxrc plugins\contrib\devpak_plugin\*.xrc -g -o plugins\contrib\devpak_plugin\plugin-xrc.cpp
+
  echo ****************************
  wxrc plugins\contrib\envvars\*.xrc -g -o plugins\contrib\envvars\plugin-xrc.cpp
+
  echo * creating core .pot files *
  wxrc plugins\contrib\help_plugin\*.xrc -g -o  plugins\contrib\help_plugin\plugin-xrc.cpp
+
  echo ****************************
wxrc plugins\contrib\IncrementalSearch\*.xrc -g -o  plugins\contrib\IncrementalSearch\plugin-xrc.cpp
+
  echo *
wxrc plugins\contrib\regex_testbed\*.xrc -g -o plugins\contrib\regex_testbed\plugin-xrc.cpp
+
  find ../sdk ../src | grep -F .cpp | grep -v svn-base | grep -v .svn | grep -v .cpp.org | xargs xgettext --keyword=_ -o codeblocks.pot 2> log.txt
  wxrc plugins\contrib\codestat\resources\*.xrc -g -o  plugins\contrib\codestat\plugin-xrc.cpp
+
  find ../sdk ../src ../include | grep -F .h | grep -v svn-base | grep -v .svn | grep -v .h.org | grep -v html | xargs xgettext --keyword=_ -o codeblocks2.pot 2>> log.txt
  wxrc plugins\contrib\profiler\resources\*.xrc -g -o  plugins\contrib\profiler\plugin-xrc.cpp
+
  find ../scripts | grep -F .script | grep -v svn-base | grep -v .svn | xargs xgettext --keyword=_ -o codeblocks3.pot 2>> log.txt
wxrc plugins\contrib\symtab\resources\*.xrc -g -o  plugins\contrib\symtab\plugin-xrc.cpp
+
  find codeblocks.pot > files.txt
if not exist po md po
+
  find codeblocks2.pot >> files.txt
xgettext -C -n -k_ -o po\plugins.pot plugins\contrib\AutoVersioning\*.h plugins\contrib\AutoVersioning\*.cpp
+
  find codeblocks3.pot >> files.txt
  xgettext -C -n -k_ -j --from-code=UTF-8 -o po\plugins.pot plugins\contrib\BrowseTracker\*.h plugins\contrib\BrowseTracker\*.cpp
+
   
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\byogames\*.h plugins\contrib\byogames\*.cpp
+
find ../plugins | grep -v contrib | grep -F .cpp | grep -v .svn | grep -v svn-base | xargs xgettext --keyword=_ -o coreplugins.pot 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\cb_koders\*.h plugins\contrib\cb_koders\*.cpp
+
  find ../plugins | grep -v contrib | grep -F .h   | grep -v .svn | grep -v svn-base | grep -v html | xargs xgettext --keyword=_ -o coreplugins2.pot 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\codesnippets\*.h plugins\contrib\codesnippets\*.cpp
+
  find coreplugins.pot >> files.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\codestat\*.h plugins\contrib\codestat\*.cpp
+
  find coreplugins2.pot >> files.txt
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\copystrings\*.h plugins\contrib\copystrings\*.cpp
+
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\devpak_plugin\*.h plugins\contrib\devpak_plugin\*.cpp
+
echo *
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\dragscroll\*.h plugins\contrib\dragscroll\*.cpp
+
  echo *******************************
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\envvars\*.h plugins\contrib\envvars\*.cpp
+
  echo * creating contrib .pot files *
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\headerfixup\*.h plugins\contrib\headerfixup\*.cpp
+
echo *******************************
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\help_plugin\*.h plugins\contrib\help_plugin\*.cpp
+
echo *
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\HexEditor\*.h plugins\contrib\HexEditor\*.cpp
+
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\IncrementalSearch\*.h plugins\contrib\IncrementalSearch\*.cpp
+
find ../plugins/contrib | grep -F .cpp | grep -v .svn | grep -v svn-base > file_c.txt
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\keybinder\*.h plugins\contrib\keybinder\*.cpp
+
find ../plugins/contrib | grep -F .h   | grep -v .svn | grep -v svn-base | grep -v html | grep -v .gch >> file_c.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\lib_finder\*.h plugins\contrib\lib_finder\*.cpp
+
  xgettext -f file_c.txt --keyword=_ -o Contribplugins.pot 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\profiler\*.h plugins\contrib\profiler\*.cpp
+
  find Contribplugins.pot >> files.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\regex_testbed\*.h plugins\contrib\regex_testbed\*.cpp
+
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\rndgen\*.h plugins\contrib\rndgen\*.cpp
+
echo *
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\source_exporter\*.h plugins\contrib\source_exporter\*.cpp
+
echo ***************************************
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\symtab\*.h plugins\contrib\symtab\*.cpp
+
echo * creating .cpp files from .xrc files *
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\ThreadSearch\*.h plugins\contrib\ThreadSearch\*.cpp
+
  echo ***************************************
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\Valgrind\*.h plugins\contrib\Valgrind\*.cpp
+
echo *
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\properties\*.h plugins\contrib\wxSmith\properties\*.cpp
+
find ../src/resources | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o src_xrc.cpp 2>> log.txt
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\propgrid\contrib\include\wx\propgrid\*.h
+
  find ../sdk/resources | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o sdk_xrc.cpp 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\propgrid\contrib\src\propgrid\*.cpp
+
  find ../plugins | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o plugins_xrc2.cpp 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\wxwidgets\*.h plugins\contrib\wxSmith\wxwidgets\*.cpp
+
  grep -v msp430x plugins_xrc2.cpp | grep -v msp430x | grep -v cc430x | grep -v jtag1 | grep -v jtag2 | grep -v jtagm | grep -v atxmega | grep -v atmega | grep -v attiny | grep -v at86 | grep -v at90 | grep -v  AT90 > plugins_xrc.cpp
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\wxwidgets\defitems\*.h plugins\contrib\wxSmith\wxwidgets\defitems\*.cpp
+
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmith\wxwidgets\properties\*.h plugins\contrib\wxSmith\wxwidgets\properties\*.cpp
+
del plugins_xrc2.cpp
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithAui\*.cpp plugins\contrib\wxSmithAui\*.h
+
   
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithAui\wxAuiManager\*.cpp plugins\contrib\wxSmithAui\wxAuiManager\*.h
+
echo *
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithAui\wxAuiNotebook\*.cpp plugins\contrib\wxSmithAui\wxAuiNotebook\*.h
+
echo *************************************************
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithAui\wxAuiToolBar\*.cpp plugins\contrib\wxSmithAui\wxAuiToolBar\*.h
+
echo * creating .pot files from those local new .cpp *
xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\*.h plugins\contrib\wxSmithContribItems\*.cpp
+
  echo *************************************************
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxchart\wxchart-1.0\src\*.cpp
+
echo *
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxchart\wxchart-1.0\include\wx\*.h
+
find . | grep -F .cpp | xargs xgettext --keyword=_ -o xrc.pot 2>> log.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxflatnotebook\*.h plugins\contrib\wxSmithContribItems\wxflatnotebook\*.cpp
+
sed "s/\$\$*/\$/g" xrc.pot > xrc.pox
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxthings\*.h plugins\contrib\wxSmithContribItems\wxthings\*.cpp
+
sed 's/\\\\\\\\/\\\\/g' xrc.pox > xrc.pot
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxthings\wxthings\include\wx\things\*.h
+
  find xrc.pot >> files.txt
  xgettext -C -n -k_ -j -o po\plugins.pot plugins\contrib\wxSmithContribItems\wxthings\wxthings\src\*.cpp
+
   
  pause
+
echo *
  rem ======= End of intl-plugin.bat =======
+
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 "Category 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 | grep -v "MSP430 1" | grep -v "MSP430 2" | grep -v "MSP430 3" | grep -v "MSP430 4" | grep -v "MSP430 5" | grep -v "MSP430 6" | grep -v "MSP430 E" | grep -v "MSP430 W" | grep -v "MSP430 MS" | grep -v "MSP430 G4" | grep -v "CC430 5" | grep -v "CC430 6" | grep -v ATmega | grep -v AT90 | grep -v ATtiny > src_xml2.cpp
 +
  xgettext -a -o xml.pox src_xml2.cpp
 +
sed "s/"/\\\\""/g" xml.pox > xml.pot
 +
  find xml.pot >> files.txt
 +
 +
echo *
 +
echo **********************
 +
  echo * Merging .pot files *
 +
echo **********************
 +
  echo *
 +
msgcat -s -f files.txt -o All_codeblocks.pox 2>> log.txt
 +
rm -f *.pot *.cpp files.txt file_c.txt
 +
  sed "s/#, c-format//g" All_codeblocks.pox > All_codeblocks.pot
 +
 +
rm -f *.pox
 +
 +
echo *
 +
echo **************
 +
echo  The END !!! *
 +
echo **************
 +
  echo on
 +
  rem ======= End of extract.cmd =======
 +
 
 +
 
  
 
== The tools for translation ==
 
== The tools for translation ==
Line 143: Line 131:
 
If Code::Blocks is compiled with Unicode, the charset should be set to utf-8; If Code::Blocks is compiled with ANSI, the charset should be set to your own language charset like gb2312, koi8-r etc.
 
If Code::Blocks is compiled with Unicode, the charset should be set to utf-8; If Code::Blocks is compiled with ANSI, the charset should be set to your own language charset like gb2312, koi8-r etc.
  
After these settings are done, you can start translating. Don't be fooled, it's a hard work! During the process, of course, you can use your translation at any time.
+
After these settings are done, you can start translating. Don't be fooled, it's a long work! During the process, of course, you can use your translation at any time.
  
 
== Create and use the .mo file ==
 
== Create and use the .mo file ==
  
Pressing Ctrl+S in poEdit, you can get a *.mo file like codeblocks.mo which is what we need. To use codeblocks.mo, we just place it into C:\Program Files\CodeBlocks\share\CodeBlocks\locale\<lang>\LC_MESSAGES or C:\Program Files\CodeBlocks\share\CodeBlocks\locale\<lang>. My language is Chinese and I have installed C::B into E:\, so I place codeblocks.mo into E:\Program Files\CodeBlocks\share\CodeBlocks\locale\zh_CN.
+
Pressing Ctrl+S in poEdit, you can get a *.mo file like codeblocks.mo which is what we need. To use codeblocks.mo, we just place it into C:\Program Files\CodeBlocks\share\CodeBlocks\locale\<lang>\. My language is French and I have installed C::B into C:\, so I place codeblocks.mo into C:\Program Files\CodeBlocks\share\CodeBlocks\locale\fr_FR.
  
If you want to use codeblocks.mo under Linux or Unix, you just place it into /usr/X11R6/share/locale/<lang>/LC_MESSAGES/. For example, I put it into /usr/X11R6/share/locale/zh_CN/LC_MESSAGES/ under FreeBSD.
+
If you want to use codeblocks.mo under Linux or Unix, you just place it into /usr/X11R6/share/locale/<lang>/LC_MESSAGES/ or in the locale\<lang< sub-directory of codeblocks, as in Windows.
  
 
Details about internationalization using wxWidgets can be found in the wxWidgets docs.
 
Details about internationalization using wxWidgets can be found in the wxWidgets docs.
Line 155: Line 143:
 
== Let Code::Blocks support your language ==
 
== Let Code::Blocks support your language ==
  
If you want Code::Blocks to support your language, you must modify the file '''\codeblocks\src\src\appglobals.cpp'''. In it, you can search for the word 'Chinese' to see the example. There are two vars about it:
+
In Code::Blocks menu, Settings, Environment, View, you'll find a check-box for Internationalization. If you check it, you'll normally find your language in the dropdown list.
 
+
const wxString langs[LANGUAGES_SIZE]
+
const int locales[LANGUAGES_SIZE]
+
 
+
== Troubleshooting ==
+
 
+
If you have any questions, you can mail to me: zxpmyth at yahoo.com.cn.
+

Revision as of 16:44, 23 December 2019


This article is about how to realize and use localized C:B. Original article written by heromyth. Reviewed by gd_on.

Get the English POT file

The url of the english POT file is at:

for the original site (but obsolete) : https://translations.launchpad.net/codeblocks/trunk/+pots/codeblocks

or

for a new site : https://translations.launchpad.net/codeblocks-gd

Old sites too : http://www.dlang.net/dl/codeblocks.pot

http://www.dlang.net/dl/plugins.pot

More information can be seen at: http://forums.codeblocks.org/index.php/topic,10204.msg70638.html. or : http://forums.codeblocks.org/index.php/topic,1022.msg159075.html#msg159075

Of course, you can run extract.cmd to generate the POT file. This tool use several unix-like tools as find, rm, grep, xargs, xgettext, msgcat. Some of them are available with many MinGW distributions or Msys2.

Note : you must use the unix-like find.exe, not the Windows one : they have not the same syntax. So, the unix-like find.exe must be found in your PATH, before the Windows one!

The tool wxrc.exe's url is http://www.dlang.net/dl/wxrc.exe (not sure it's sill available there). Or you can find the source in wxWidgets/utils and build it.

The content of extract.cmd is below:

rem ======= Begin of extract.cmd =======

@echo off
echo ****************************
echo * creating core .pot files *
echo ****************************
echo * 
find ../sdk ../src | grep -F .cpp | grep -v svn-base | grep -v .svn | grep -v .cpp.org | xargs xgettext --keyword=_ -o codeblocks.pot 2> log.txt
find ../sdk ../src ../include | grep -F .h  | grep -v svn-base | grep -v .svn | grep -v .h.org | grep -v html | xargs xgettext --keyword=_ -o codeblocks2.pot 2>> log.txt
find ../scripts | grep -F .script | grep -v svn-base | grep -v .svn | xargs xgettext --keyword=_ -o codeblocks3.pot 2>> log.txt
find codeblocks.pot > files.txt
find codeblocks2.pot >> files.txt
find codeblocks3.pot >> files.txt

find ../plugins | grep -v contrib | grep -F .cpp | grep -v .svn | grep -v svn-base | xargs xgettext --keyword=_ -o coreplugins.pot 2>> log.txt
find ../plugins | grep -v contrib | grep -F .h   | grep -v .svn | grep -v svn-base | grep -v html | xargs xgettext --keyword=_ -o coreplugins2.pot 2>> log.txt
find coreplugins.pot >> files.txt
find coreplugins2.pot >> files.txt

echo *
echo *******************************
echo * creating contrib .pot files *
echo *******************************
echo *

find ../plugins/contrib	| grep -F .cpp | grep -v .svn | grep -v svn-base > file_c.txt
find ../plugins/contrib | grep -F .h   | grep -v .svn | grep -v svn-base | grep -v html | grep -v .gch >> file_c.txt
xgettext -f file_c.txt --keyword=_ -o  Contribplugins.pot 2>> log.txt
find Contribplugins.pot >> files.txt

echo *
echo ***************************************
echo * creating .cpp files from .xrc files *
echo ***************************************
echo *
find ../src/resources | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o src_xrc.cpp 2>> log.txt
find ../sdk/resources | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o sdk_xrc.cpp 2>> log.txt
find ../plugins | grep -F .xrc | grep -v .svn | grep -v svn-base | xargs wxrc -g -o plugins_xrc2.cpp 2>> log.txt
grep -v msp430x plugins_xrc2.cpp | grep -v msp430x | grep -v cc430x | grep -v jtag1 | grep -v jtag2 | grep -v jtagm | grep -v atxmega | grep -v atmega | grep -v attiny | grep -v at86 | grep -v at90 | grep -v  AT90 > plugins_xrc.cpp

del plugins_xrc2.cpp

echo *
echo *************************************************
echo * creating .pot files from those local new .cpp *
echo *************************************************
echo *
find . | grep -F .cpp | xargs xgettext --keyword=_ -o xrc.pot 2>> log.txt
sed "s/\$\$*/\$/g" xrc.pot > xrc.pox
sed 's/\\\\\\\\/\\\\/g' xrc.pox > xrc.pot
find xrc.pot >> files.txt

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 "Category 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 | grep -v "MSP430 1" | grep -v "MSP430 2" | grep -v "MSP430 3" | grep -v "MSP430 4" | grep -v "MSP430 5" | grep -v "MSP430 6" | grep -v "MSP430 E" | grep -v "MSP430 W" |  grep -v "MSP430 MS" | grep -v "MSP430 G4" | grep -v "CC430 5" | grep -v "CC430 6" | grep -v ATmega | grep -v AT90 | grep -v ATtiny > src_xml2.cpp
xgettext -a -o xml.pox src_xml2.cpp
sed "s/"/\\\\""/g" xml.pox > xml.pot
find xml.pot >> files.txt

echo *
echo **********************
echo * Merging .pot files *
echo **********************
echo *
msgcat -s -f files.txt -o All_codeblocks.pox 2>> log.txt
rm -f *.pot *.cpp files.txt file_c.txt
sed "s/#, c-format//g" All_codeblocks.pox > All_codeblocks.pot

rm -f *.pox

echo *
echo **************
echo  The END !!! *
echo **************
echo on
rem ======= End of extract.cmd =======


The tools for translation

Usually, we use the poEdit tool which can be downloaded here. Of course, you can do the translation at https://translations.launchpad.net.

Translating with poEdit

Rename codeblocks.pot into codeblocks.po. Use poEdit to open the file codeblocks.po. Change a few settings like:

[File]->[Preferences]->[Personalize]

[Catalog]->[Settings]->[Project info]->[Team/email/Language/Charset]

If Code::Blocks is compiled with Unicode, the charset should be set to utf-8; If Code::Blocks is compiled with ANSI, the charset should be set to your own language charset like gb2312, koi8-r etc.

After these settings are done, you can start translating. Don't be fooled, it's a long work! During the process, of course, you can use your translation at any time.

Create and use the .mo file

Pressing Ctrl+S in poEdit, you can get a *.mo file like codeblocks.mo which is what we need. To use codeblocks.mo, we just place it into C:\Program Files\CodeBlocks\share\CodeBlocks\locale\<lang>\. My language is French and I have installed C::B into C:\, so I place codeblocks.mo into C:\Program Files\CodeBlocks\share\CodeBlocks\locale\fr_FR.

If you want to use codeblocks.mo under Linux or Unix, you just place it into /usr/X11R6/share/locale/<lang>/LC_MESSAGES/ or in the locale\<lang< sub-directory of codeblocks, as in Windows.

Details about internationalization using wxWidgets can be found in the wxWidgets docs.

Let Code::Blocks support your language

In Code::Blocks menu, Settings, Environment, View, you'll find a check-box for Internationalization. If you check it, you'll normally find your language in the dropdown list.