gettext and "disambiguating comments"

T

Terry Hancock

I'm looking at the gettext module for the first time and
learning how to write internationalized code in Python.

Naturally, I also looked at the original Gnu gettext
manual, which mentions that comments can be captured
into the .po (.pot?) file for translators' benefit:

/* Comment right before the gettext call, obviously in C */
printf(_("Apparently ambiguous string to translate"));

This will get captured into the .po file, according to the
gettext manual and appear as a comment right before
the msgid (i.e. next to the line number reference).

Is there an equivalent Python gettext idiom? I've tried the
obvious

# Comment right before the gettext call, now in Python
print _("Apparently ambiguous string to translate")

But this is ignored by both pygettext and xgettext.

I also saw some discussion (from the Gnome project)
about gettext variations which capture comments from
within the text:

_("comment for translators| Spam")

But, Python's gettext happily renders the entire comment
into the program, so this isn't doing anything either.

Clearly, I could edit the .pot file after creation to
include comments, but that's probably undesireable
since the file is meant to be machine-generated.

I have no pressing immediate need for this functionality
(that I know of), but I'd like to understand how to access
this capability if it exists.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Terry said:
/* Comment right before the gettext call, obviously in C */
printf(_("Apparently ambiguous string to translate"));

This will get captured into the .po file, according to the
gettext manual and appear as a comment right before
the msgid (i.e. next to the line number reference).

Not automatically. You need to pass the -c option to xgettext
to make that happen, preferably using a tag:

/* TRANSLATORS: Comment right before the gettext call */
Is there an equivalent Python gettext idiom? I've tried the
obvious

# Comment right before the gettext call, now in Python
print _("Apparently ambiguous string to translate")

But this is ignored by both pygettext and xgettext.

Did you give -c to xgettext? It works for me, for xgettext
0.14.5. -c appears to be unimplemented in pygettext.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top