Translatable strings in .h file -- best way to resolve?

Christian Stimming stimming at tuhh.de
Tue Mar 16 05:17:37 EDT 2010


Zitat von Jeff Kletsky <gnucash at allycomm.com>:
> #define ACCOUNT_OPTIONS_SECTION "Accounts"
> #define TRADING_ACCOUNTS_OPTION "Trading Accounts"
>
> Presently, make-gnucash-potfiles.in does not look at .h files for  
> translatable strings, so even after adding
> #include <glib/gi18n.h>
> and marking the strings, they don't make it into POTFILES.in
>
> What approach is recommended for resolving this?
>
> * Add an exception to make-gnucash-potfiles.in

Yes.

> * Use _(ACCOUNTS_OPTIONS_SECTION) and don't translate the raw define

Yes. In the #define lines, the strings should be marked with the N_(  
... ) macro, so they are still just a const char* literal for the  
compiler's point of view, but they make it into gnucash.pot:

#include <glib/gi18n.h>
#define ACCOUNT_OPTIONS_SECTION N_("Accounts")

Subsequently, in places where the defines are being used for  
human-visible display, they need to be translated writing  
_(ACCOUNTS_OPTIONS_SECTION).

> * Change .h to .c and leave people wondering why a .c file is being  
> #include-d

No.

Is that explanation sufficient or did I still forget something?

Regards,

Christian



More information about the gnucash-devel mailing list