Barry Warsaw writes:

 > The problem is that
 > 
 >      _("some string"
 >        " and more of it")
 > 
 > is not the same as
 > 
 >      _("some string" +
 >        " and more of it")

Are you worried about translators?  The gettext functions themselves
will just see the result of the operation.  The extraction tools like
xgettext do fail, however.  Translating the above to

# The problem is that

        gettext("some string"
          " and more of it")

# is not the same as
 
        gettext("some string" +
          " and more of it")

and invoking "xgettext --force-po --language=Python test.py" gives

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <[EMAIL PROTECTED]>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-05-03 23:32+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n"
"Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: test.py:3
msgid "some string and more of it"
msgstr ""

#: test.py:8
msgid "some string"
msgstr ""

BTW, it doesn't work for the C equivalent, either.

 > You would either have to teach pygettext and maybe gettext about
 > this construct, or you'd have to use something different.

Teaching Python-based extraction tools about it isn't hard, just make
sure that you slurp in the whole argument, and eval it.  If what you
get isn't a string, throw an exception.  xgettext will be harder,
since apparently does not do it, nor does it even know enough to error
or warn on syntax it doesn't handle within gettext()'s argument.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to