Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A string, for example "hello world" is set to be translated from the C/C++ code by calling a special function, named _
For example you should write: _("hello world"In this case instead of [_ ] you have to use the macro _() to enclose the string to translate,
For example:

Code Block
printf ("hello world");

You must write

Code Block
printf (_ ("hello world"));

In C/C ++ there is no the Tcl casuistry due to substitution, and the parameters are written as desired after the format string:
For example:

Code Block
printf("User %s running %i threads",username,nproc);

Must be written

Code Block
printf(_("User %s running %i threads"),username,nproc);


As in Tcl, care must be taken not to try to translate keywords, program "includes", and so on.

To include the macro _() in any project, without dragging other declarations of unwanted functions, it has been isolated from the "Main.h" file to a new header file, called "Trad.h"

As an alternative to Msgcat, the option of using gettext was considered, but it was discarded due to several inconveniences:
It is originally from UNIX platforms, you have to tweak it for Windows.
It only works for C/C ++ files, but not for Tcl files.
It has a string extraction program but only for C/C ++, not for Tcl.
Msgcat is suitable for Tcl and C/C ++, and comes standard with Tcl (thus ensuring maintenance)