[Python-Dev] [Python-3000] PEP 30XZ: Simplified Parsing (original) (raw)
Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Thu May 3 16:40:03 CEST 2007
- Previous message: [Python-Dev] [Python-3000] PEP 30XZ: Simplified Parsing
- Next message: [Python-Dev] [Python-3000] PEP 30XZ: Simplified Parsing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 at ADDRESS>, 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 at ADDRESS>\n" "Language-Team: LANGUAGE <LL at li.org>\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.
- Previous message: [Python-Dev] [Python-3000] PEP 30XZ: Simplified Parsing
- Next message: [Python-Dev] [Python-3000] PEP 30XZ: Simplified Parsing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]