imupdate

Created08.07.2005
Last modified10.07.2005

Main module for the imupdate program.  It extracts translatable strings from D source files and inserts them into message catalogues in the TS format (an XML text format).  See Message translation for general explanations, and imupdate program for further program description.

Summary
The “imupdate” program reads D source files and extracts all translatable strings from them.

imupdate program

The “imupdate” program reads D source files and extracts all translatable strings from them.  It then writes them to message catalogues in the TS format (an XML text format compatible to the one used by Qt).

The usage is very simple: Call the program with the names of all D source files that are to be read, and the name of the “.ts” file to write after the “--ts” option.  The sources will be read, and if the TS file exists it will be read in, too.  The new messages are then merged into the old ones.  Identical strings retain their translations and are marked finished, new strings similar to old ones get the old translations as a start and are marked unfinished, and old strings that are no longer used are marked obsolete.

There are a couple of things you have to adhere to in your source files, to ensure that imupdate does its work.  You have to explicitly declare the module name, and calls to i18n() and i18n_g() have to be “clean”, that means without concatenation operators, word puzzles or similar tricks. imupdate will complain otherwise.  You can use WYSIWYG strings and all the useful escape sequences D offers.  You cannot use hexadecimal strings, though.

If you want to insert a standalone comment for the translator, use a “magic comment” that begins with the word TRANSLATOR.  It can be put into line or block comments.

/* TRANSLATOR
You can reach all the messages in this module if you choose »create
project« in the main menu.
*/

In the Qt Linguist this comment will show up as an additional comment for all messages in the module, for example.

This is a sample session, where the “-v” (verbose) option was specified to produce some enlightening output:

[uwe@sandmann indigo]$ ./imupdate -v test.d test2.d --ts test.ts
Processing file »test.d«.
Processing file »test2.d«
2 contexts read.
5 finished, 23 unfinished and 4 obsolete messages.
Writing output to »test.ts«.
Finished.
Message translation is the first step to an internationalized application.
The “imupdate” program reads D source files and extracts all translatable strings from them.
This function translates the source string.
extern (
   C
) public char[] i18n_g(char[] context, char[] source, char[] comment = null)
This is a globally available function that translates the source string.