Use of #define statements with translatable strings

Alex Aycinena alex.aycinena at gmail.com
Sun Mar 31 20:50:52 EDT 2013


Derek & Christian,

Thanks for the quick responses.

On Sun, Mar 31, 2013 at 2:41 PM, Christian Stimming
<christian at cstimming.de>wrote:

> Am Sonntag, 31. März 2013, 14:22:24 schrieb Alex Aycinena:
> >
> > #define CUT_TRANSACTION_LABEL         N_("Cu_t Transaction")
> > #define COPY_TRANSACTION_LABEL        N_("_Copy Transaction")
> > ...
> > #define CUT_SPLIT_LABEL               N_("Cu_t Split")
> > #define COPY_SPLIT_LABEL              N_("_Copy Split")
> > ...
> >
> >
> > Can anyone help me out here? I'm not sure how to proceed.
>
> For the translation to work, two steps need to work correctly:
>
> 1. The strings must be marked in the source for extraction by the external
> tool "xgettext", which copies them from the *.c files to the *.po files
> (with
> gnucash.pot as intermediate template). This is a compile-time step.
>
> 2. At runtime, the English strings must be passed through the function
> gettext( ).
>
> To get a string to be extracted (step #1), you must mark the strings by
> any of
> the macros mentioned in the gettext documentation - either N_( ), or _( ),
> or
> S_( ) or whatever other macro exists. However, the macro must go around the
> real string, not around any macro names. In your case, this is done
> correctly.
>
> To get a string to be passed through gettext( ) at runtime, the strings can
> either be enclosed by _( ), which expands at compile time to a call to
> gettext( ). Alternatively, the const char* pointers from the strings can be
> passed through gettext( ) or _( ) manually at some later point.
>
> In your case, I don't know where you're using those macros. If they are
> used
> in a place where the strings are expected in already translated form, N_( )
> was wrong and you need to use _( ) instead. Alternatively, you can also use
> _(CUT_SPLIT_LABEL) in the places where you need the translated string, and
> CUT_SPLIT_LABEL where you need the not-yet-translated static string.
> Depends
> on the context.
>
> Regards,
>
> Christian
>

I solved it by using _( ) around the const char* pointers as you suggested.
So now I'm ready to commit, but when I try do do so I get the following:

[gnucash-dev at HPs7700nFedora gnucash-working]$ svn commit -m "Vary some menu
labels and tooltips based on cursor class: transaction or split."
svn: E175013: Commit failed (details follow):
svn: E175013: Access to
'/repo/!svn/act/ef89d07d-f40e-4fe6-a2f6-6b123a7e881a' forbidden
[gnucash-dev at HPs7700nFedora gnucash-working]$

Any idea why this is happening? It's worked until recently.

Regards,

Alex


More information about the gnucash-devel mailing list