469,621 Members | 1,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

gettext and "disambiguating comments"

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.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com

Jul 21 '05 #1
1 1889
Terry Hancock wrote:
/* 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
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Trebor A. Rude | last post: by
2 posts views Thread by George Sew | last post: by
12 posts views Thread by Matthew Wilson | last post: by
2 posts views Thread by Bill H | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.