contents
Translate

GnuGetText tools for Delphi


Additional tools

GgtTranslate - Create and manage translations

This program provides a graphical user interface for the creation and management of multilingual translations. All the functions described here are combined under one roof:


The settings, e.g. the name of the text domain or the languages used, are saved separately for each project in a dxgettext.ini file, which is located in the respective project directory. When the project directory is changed, the corresponding settings will be automatically loaded.

Settings


Actions

Clicking on one of the large buttons at the bottom right will start one of the following actions:


PoCompare - Compare po files

Sometimes it is necessary to compare translations, e.g. when a revised version is available, or to transfer translations from one project to another. PoCompare loads two translated po files, the one to be edited and the one to be used for comparison, and searches for all entries where the original text (msgid) is the same and the translation (msgstr) is different. The number of entries found is displayed at the top, with a selected entry below:

Selection of the po files to used:
  First select the po file to be edited by clicking on this button at the top left. Then select the po file to be used for comparison by clicking on the button at the top right.
  To find the comparison file more quickly, the search can be started directly in the directory of the po file to be edited by clicking on this button.
These buttons can be used to navigate through the entries found:
  One entry forwards or backwards
  10 entries forwards or backwards
  Go to the first or last entry
These buttons are used for editing:
  The text of the selected entry is copied from right to left, i.e. the translation on the left is replaced by the one on the right. Entries changed in this way are highlighted in color.
  All entries are copied from right to left.
  It is also possible to make changes manually in the left-hand translation window. These must then be confirmed by clicking on the OK button.
  This can be used to undo the last change.
  Clicking this button will save the changes to the left po file.
Further functions:
  Edit the drop-down list of po files to be edited
  Reload both po files
  Open the po file to be edited with the associated editor (e.g. PoEdit)

Command line

Calling: pocompare.exe <editname> <refname>
  <editname> po file to be edited
  <refname> po file to be used for comparison

Import of translations from another po file

Sometimes you need translations for a new project that are already available for another project. With PoImport, these can be transferred quickly and easily. First, the two po files are loaded, the new one to be edited (Po-1) and the one already available in translated form (Po-2). The program checks for all entries in Po-1 whether

  1. there is no translation yet, i.e. msgstr is empty,
  2. a suitable entry exists in Po-2 (identical msgid).

If this is the case, the translation msgstr is copied from Po-2 to Po-1. The updated po file (Po-1) is then saved.
If necessary, i.e. if there are more untranslated strings in Po-1, you can repeat the import with other po files to complete the translation.


PoFromPas - Extract translations from the resource strings of Pascal units

If there is already a translation into a language other than English for a Delphi unit, the resource strings used there (strings defined in the resourcestring section) can be transferred to a po file. To identify the strings, their constant name, e.g. SFileNotFound from the System.SysConst.pas unit, is used. In the po template, this is marked by dxgettext or GgtTranslate as a comment with the note Programmer's name for it:.



TransUnit - Create a translated Delphi unit with the strings from a po file

This program can be used to create a unit with the translated strings from a Delphi unit (dfm and pas file) in the base language (e.g. English). The translations are extracted from an already translated po file.

In the overview, all strings (msgid) found in the Delphi unit and in the po file are displayed in a list. The origin of the respective string can be seen in the middle column: D = form (dfm file) and P = source text (pas file). To the right is the translation found in the po file. All strings for which a translation was found are automatically marked (check mark on the left-hand side). If necessary, the user can adjust this selection manually. After clicking on the Replace strings button, the translations of the marked strings are inserted into the two files of the Delphi unit. In addition, the unit GnuGetText (if specified) is replaced by the dummy unit GgtDummy in the uses statement. This means that any functions _(..), dgettext(..) and TranslateComponent(..) used in the source text can remain unchanged. The Delphi unit files changed in this way are then stored in a subdirectory of the original with the abbreviation of the respective language as the name.



PoSpell - Spell check of translated po files

This program can be used to check a po file for spelling errors. It uses the dictionaries from the Hunspell project, which are also used in many other applications such as LibreOffice, OpenOffice and Firefox. The German dictionary is already included in the installation package. However, any other dictionary can also be selected. There is also a private dictionary for the user, in which he collects all expressions that are not included in the global dictionary but are recognized as correctly spelled

Procedure

After selecting a po file, the program automatically searches for the first suspected spelling error in a translation (msgstr) and displays it in the middle window. Below this, the supposedly misspelled word is highlighted. You now have various options:

  1. Add to dictionary ...: The displayed word is added to the private dictionary so that it is recognized as correct in future checks. The next word is then searched for.
  2. Replace word: First correct the word manually or click on the ↓ arrow to select the correct word from a list of possible suggestions. Then click on this button to replace the word and then on Next word.
  3. Next word: The supposedly incorrect text is ignored and the next word is searched for.

Finally, click on the Save button on the right to save the changes.

Command line

Calling: pospell.exe <poname>
  <poname> po file to checked


PoStat - Display of the header and statistics of a po file

The header of the po file with information on the project, the author, the translator will be displayed, as well as the statistics of the entries..

Command line

Calling: postat.exe <poname>
  <poname> po to be displayed


PoComment - Save translated strings as comment

If a translator has difficulties understanding the English texts, this program can be used to insert the existing translation into another language as a comment in the new translation. In PoEdit, these comments are displayed in addition to the original English texts in the bottom right-hand field as a note and help the translator to better understand the text.



Translating texts for InnoSetup scripts

A widely used application for creating installation archives is the freeware program Inno Setup. It offers the option of integrating the information texts required for the user interface during installation in various languages. The programs offered here can be used to create the required text files with the translations via PoEdit.

Processing takes place in the following steps:

  1. The IssToPas program is used to extract the texts of the [CustomMessages] section in the InnoSetup script and convert these as resource strings into a Delphi unit (Pascal).
  2. A po template and the corresponding translated po file are created from the unit generated in this way using GgtTanslate or dxgettext and ggmerge.
  3. The PoToIss program is used to create a text file in a format that can be integrated into the InnoSetup script.

IssToPas

Extracts the texts of the [CustomMessages] section in the InnoSetup script and converts them as resource strings into a Pascal unit. The following example shows the texts in the setup script on the left and the Delphi unit generated from them on the right:

Text of the iss file:   Text of the Delphi unit
 
    
    
  [CustomMessages]     
  en.ProgName=Personal Backup %1 (%2-bit)
  en.eventicon=Add messages to event log
  en.Context=Context menus:
  ...
    
 
    
  unit InstallStrings;
  interface
  resourcestring
    ProgName = 'Personal Backup %1 (%2-bit)';
    eventicon = 'Add messages to event log';
    Context = 'Context menus:';
    ...
  implementation
  end.
    
Command line:
Calling: isstopas.exe <issname> [options]
  <issname> Name of the iss file from which the text strings are to be extracted.
  /prefix:<langid> <langid> is the ISO 639 code of the language to be extracted (only required if other than en).
  /out:<pasname> Use a different unit name (instead of issname.pas).

Examples:
  isstopas.exe E:\Sample\test.iss
  isstopas.exe E:\Sample\test.iss /pref:de /out:testde

PoToIss

Converts the translated texts from a po file into the format that can be integrated into an InnoSetup script.


Command line:
Calling: potoiss.exe <poname> [options]
  <poname> Name of the po file whose strings are to be converted.
  /prefix:<langid> <langid> is the ISO 639 code of the language to be processed.
  /out:<outname> Name of the output file (if other than poname.txt).


Integration of the additional functions into the Windows context menus

When the program package is installed, the necessary registry entries are automatically made to adapt the Windows context menus. In addition to the basic functions already described, there are extended context menus for the additional functions listed above:

3. Right-click on a po file, e.g. default.po   2. Right-click on an iss file, e.g. GgtTranslate.iss
opens the selected po file with the respective tool (see the descriptions above).   extracts the texts of the [CustomMessages] section (see above under IssToPas).


J. Rathlev, D-24222 Schwentinental, October 2024