gettext and "disambiguating comments"

Discussion in 'Python' started by Terry Hancock, Jul 11, 2005.

  1. 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
    Terry Hancock, Jul 11, 2005
    #1
    1. Advertising

  2. 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
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Jul 11, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Leidert
    Replies:
    0
    Views:
    669
    Daniel Leidert
    May 28, 2005
  2. Hans-Joachim Widmaier

    gettext and the interpreter

    Hans-Joachim Widmaier, Apr 3, 2004, in forum: Python
    Replies:
    2
    Views:
    290
    Hans-Joachim Widmaier
    Apr 8, 2004
  3. Daniele
    Replies:
    2
    Views:
    385
    Daniele
    Oct 14, 2004
  4. =?iso-8859-1?B?QW5kcuk=?=
    Replies:
    0
    Views:
    418
    =?iso-8859-1?B?QW5kcuk=?=
    Mar 2, 2006
  5. KW

    XSLT and gettext?

    KW, Mar 2, 2006, in forum: Python
    Replies:
    1
    Views:
    359
Loading...

Share This Page