AutoGen - The Automated Program Generator: 7.15 Internationalizing AutoOpts

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 7.15 Internationalizing AutoOpts

The generated code for AutoOpts will now enable and disable the translation of AutoOpts run time messages. If `ENABLE_NLS` is defined at compile time, then the `_()` macro may be used to specify a translation function. If undefined, it will default to `gettext(3GNU)`. `ENABLE_NLS` will enable a callback function that `optionProcess` will invoke at the beginning of option processing. The strings returned by the translation function will be `strdup(3)-ed` and kept. They will not be re-translated, even if the locale changes, but they will also not be dependent upon reused or unmappable memory.

To internationalize option processing, you should first internationalize your program. Then, the option processing strings can be added to your translation text by processing the AutoOpts-generated ``my-opts.c'` file and the distributed ``usage-txt.h'` file. The latter file contains all of the user display strings used by AutoOpts. It can be extracted for your use, for example, as in:

    xgettext --omit -a -Lc -oopts.po $prefix/include/usage-txt.h

Simply run ``xgettext'`, or equivalent, on the distributed header, ``usage-txt.h'` and add it to the rest of your `i18n`. When you call `optionProcess`, all of the user visible AutoOpts strings will be passed through the localization procedure established with the `_()` preprocessing macro.

The AutoOpts `libopts` library will always check for the "compiled with NLS" flag, so `libopts` does not need to be specially compiled.

This document was generated by Bruce Korb on April, 9 2006 using texi2html 1.76.