In this guide I will explain how to simplify the localization process of a software written in c++ using “wxWidget (a cross platform toolkit), with poEdit.
poEdit offers to developers a conventient approach to localizazion, and there is no need to modify the source code by hand to modify translations, because they are all stored on a catalog file that is easy editable.

Logo poEdit

To prepare the source code to the localization, we must sorround all strings that we want to localize with the macro “_()”, for example:

...
wxMessageBox( _("localized string") );
...
wxMessageBox( wxT("not localized string") );


When all strings to translate are sorrounded with the macro, we can start the translation process launching poEdit: when we run the program for the first time, it will ask us general information about the team, the author of the translation, the language and other boredoms.

poEdit Preferences

When the program has been started go to “File”, “New Catalog”

poEdit new project settings

Compile the “Project info” tab as in picture, go to the “Paths” tab and add the source code path in the “Base path” text box and in the paths list below.
Click “Ok” and save your “.po” file in the project directory.
Now you can see a summary windows that shows all strings that you can to translate:

poEdit Update Summary

If you get an error, don’t worry! Go on “Catalog” -> “Update from sources” and all should go right.

poEdit Main Window

Now go to “View” -> “Display quotes” and start the translation! In the left bottom textbox you can insert the the translation of the string, inside the quotes.
When you finish the translation you can save, and you’ll find in the project directory the files “default.po” and “default.mo”. The file “.mo” is the real localization file, but if you want to change the translation use the “.po” file, so don’t delete it.

Part 2 of the article “Localization of a c++ wx project (using poEdit)” will be published soon.


Se sei interessato a questo post, potresti anche provare a leggere:

  • No related posts