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

7.16 Internationalizing AutoOpts

The generated code for AutoOpts will enable and disable the translation of AutoOpts run time messages. If ENABLE_NLS is defined at compile time and no-xlate has been not set to the value anything, then the _() macro may be used to specify a translation function. If undefined, it will default to gettext(3GNU). This define will also enable a callback function that optionProcess invokes at the beginning of option processing. The AutoOpts libopts library will always check for this compiled with NLS flag, so libopts does not need to be specially compiled. 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.

You should also ensure that the ATTRIBUTE_FORMAT_ARG() gets #define-ed to something useful. There is an autoconf macro named AG_COMPILE_FORMAT_ARG in ‘ag_macros.m4’ that will set it appropriately for you. If you do not do this, then translated formatting strings may trigger GCC compiler warnings.

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 adding the distributed ‘po/usage-txt.pot’ file. (Also by extracting the strings yourself from the ‘usage-txt.h’ file.) When you call optionProcess, all of the user visible AutoOpts strings will be passed through the localization procedure established with the _() preprocessing macro.

All of this is dis-abled if you specify the global attribute no-xlate to anything.

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

This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.