Internationalization: Difference between revisions

From Code::Blocks
mNo edit summary
Proofreading and formatting
Line 3: Line 3:
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. All the works have been done under Windows XP SP2.


'''1. Getting english POT file'''
'''1. Get the English POT file'''


The english POT file's url is here:
The english POT file's url is here:
Line 9: Line 9:
https://developer.berlios.de/patch/?func=detailpatch&patch_id=822&group_id=5358
https://developer.berlios.de/patch/?func=detailpatch&patch_id=822&group_id=5358
   
   
I will update this file aperiodically. Of course, you can use the tool which I have created (seen belown) to generate the POT file.
I will update this file periodically. Of course, you can use the tool which I have created (seen belown) to generate the POT file.


The content of the tool which is named as '''intl.bat''' is belown:
The content of the tool which is named as '''intl.bat''' is belown:


rem ======= Begin of intl.bat =======
rem ======= Begin of intl.bat =======
 
@echo off
@echo off
 
wxrc src\resources\*.xrc -g -o  src\src-xrc.cpp
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 sdk\resources\*.xrc -g -o  sdk\sdk-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\astyle\resources\*.xrc -g -o  plugins\astyle\astyle-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\classwizard\resources\*.xrc -g -o  plugins\classwizard\classwizard-xrc.cpp
wxrc plugins\defaultmimehandler\resources\*.xrc -g -o  plugins\defaultmimehandler\defaultmimehandler-xrc.cpp
 
wxrc plugins\pluginwizard\resources\*.xrc -g -o  plugins\pluginwizard\pluginwizard-xrc.cpp
wxrc plugins\codecompletion\resources\*.xrc -g -o  plugins\codecompletion\codecompletion-xrc.cpp
wxrc plugins\todo\resources\*.xrc -g -o  plugins\todo\todo-xrc.cpp  
 
wxrc plugins\compilergcc\resources\*.xrc -g -o  plugins\compilergcc\compilergcc-xrc.cpp
if not exist po md po
 
wxrc plugins\debuggergdb\resources\*.xrc -g -o  plugins\debuggergdb\debuggergdb-xrc.cpp
xgettext -C -n -k_ -o po\codeblocks.pot src\*.cpp src\*.h
 
xgettext -C -n -k_ -j -o po\codeblocks.pot src\wxAUI\*.cpp src\wxAUI\*.h
wxrc plugins\defaultmimehandler\resources\*.xrc -g -o  plugins\defaultmimehandler\defaultmimehandler-xrc.cpp
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\*.cpp sdk\*.h
 
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\bindings\*.cpp sdk\as\bindings\*.h
wxrc plugins\pluginwizard\resources\*.xrc -g -o  plugins\pluginwizard\pluginwizard-xrc.cpp
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\propgrid\src\propgrid\*.cpp sdk\propgrid\include\wx\propgrid\*.h
 
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxFlatNotebook\*.cpp
wxrc plugins\todo\resources\*.xrc -g -o  plugins\todo\todo-xrc.cpp
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\include\*.h
if not exist po md po
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\source\*.cpp sdk\as\source\*.h
 
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxscintilla\*.cpp sdk\wxscintilla\*.h
xgettext -C -n -k_ -o po\codeblocks.pot src\*.cpp src\*.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 src\wxAUI\*.cpp src\wxAUI\*.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 sdk\*.cpp sdk\*.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 sdk\as\bindings\*.cpp sdk\as\bindings\*.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 sdk\propgrid\src\propgrid\*.cpp sdk\propgrid\include\wx\propgrid\*.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\pluginwizard\*.cpp plugins\pluginwizard\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxFlatNotebook\*.cpp
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
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\include\*.h
pause
 
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\source\*.cpp sdk\as\source\*.h
rem ======= End of intl.bat =======
 
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxscintilla\*.cpp sdk\wxscintilla\*.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\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\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\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\pluginwizard\*.cpp plugins\pluginwizard\*.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 =======


'''2. Getting the translating tool'''
'''2. Get the translating tool'''


Usually, we use the tool of poEdit which can be down at http://www.poedit.org/download.php.
Usually, we use the poEdit tool which can be downloaded at http://www.poedit.org/download.php.


'''3. Translating in poEdit'''
'''3. Translating in poEdit'''


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


like:
[File]->[Preferences]->[Personalize]
[File]->[Preferences]->[Personalize]


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


If your C:B is compiled with UNICODE, the Charset should be setted to utf-8; If C:B is compiled with ANSI, the Charset should be setted to your own language charset like gb2312,koi8-r etc..
If your C::B is compiled with UNICODE, the Charset should be set to utf-8; If C::B is compiled with ANSI, the Charset should be set to your own language charset like gb2312, koi8-r etc.


After these settings done, you can start the translating. It's a hard working! During the process, of course, you can use your translations an any time.  
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.  


'''4. Getting and using mo file'''
'''4. Create and use the .mo file'''


Pressing Ctrl+S in poEdit, you can get a *.mo file like codeblocks.mo which is needed by we. To use codeblocks.mo, we just place it into C:\Program Files\CodeBlocks or 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 or 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.


If wanting 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/. For example, I put it into /usr/X11R6/share/locale/zh_CN/LC_MESSAGES/ under FreeBSD.


Details about Internationalization of wxWidget can be seen from wxWidget's docment.
Details about internationalization of wxWidgets can be found in the wxWidgets docs.


'''5. Troubleshooting'''
'''5. Troubleshooting'''


If having any questions, you can mail to me: zxpmyth at yahoo.com.cn.
If you have any questions, you can mail me: zxpmyth at yahoo.com.cn.

Revision as of 08:34, 13 June 2006


This article is about how to realize and use localized C:B. All the works have been done under Windows XP SP2.

1. Get the English POT file

The english POT file's url is here:

https://developer.berlios.de/patch/?func=detailpatch&patch_id=822&group_id=5358

I will update this file periodically. Of course, you can use the tool which I have created (seen belown) to generate the POT file.

The content of the tool which is named as intl.bat is belown:

rem ======= Begin of intl.bat =======

@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\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\pluginwizard\resources\*.xrc -g -o  plugins\pluginwizard\pluginwizard-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 src\*.cpp src\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot src\wxAUI\*.cpp src\wxAUI\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\*.cpp sdk\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\bindings\*.cpp sdk\as\bindings\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\propgrid\src\propgrid\*.cpp sdk\propgrid\include\wx\propgrid\*.h
xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxFlatNotebook\*.cpp
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\include\*.h
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\as\source\*.cpp sdk\as\source\*.h
rem xgettext -C -n -k_ -j -o po\codeblocks.pot sdk\wxscintilla\*.cpp sdk\wxscintilla\*.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\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\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\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\pluginwizard\*.cpp plugins\pluginwizard\*.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 =======

2. Get the translating tool

Usually, we use the poEdit tool which can be downloaded at http://www.poedit.org/download.php.

3. Translating in 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 your C::B is compiled with UNICODE, the Charset should be set to utf-8; If C::B 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.

4. 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 or 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.

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.

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

5. Troubleshooting

If you have any questions, you can mail me: zxpmyth at yahoo.com.cn.