This document applies to the latest version. If you haven't got the latest version, please download it now. 1) Modify your source code.Add gnugettext.pas to your project. Add gnugettext to the uses clause of all units that contains forms. Add the following line to the OnFormCreate event of your forms: TranslateComponent (self); Add typical ignores just before the TranslateComponent (self) you put in the main form. |
| File | Description |
|---|---|
| appdir/application.exe | Your application |
| appdir/locale/da/LC_MESSAGES/default.mo | Danish translations |
| appdir/locale/de/LC_MESSAGES/default.mo | German translations |
| appdir/locale/de_AT/LC_MESSAGES/default.mo | German translations for Austria |
The directory names for the different languages are either just the two-letter ISO 639 language code or a combination of the ISO 639 language code and the ISO 3166 country code.
In the above example, if the program was running on a German computer, it would first search for the de_DE directory, and then for the de directory because de_DE does not exist.
6) Consider to make a single-file version
You can avoid all the .mo files by including them inside your .exe file. In order to do this, you must first make sure that the above works, and then you right click the .exe file and choose "GG Embed translations":
This will append all the .mo files to the .exe file in a way that makes the .exe file self-contained.
Important tips
- If you did everything above, you will have translated all strings in your user interface and all resourcestrings. Using resourcestrings works great, but it works much better if you would consider to use the _() syntax instead.
- GNU gettext is designed for translating English language programs to other languages. It is possible to translate from other languages, too, but then the program will be limited to run on computers that use the same character set in ansistrings.

