Closed tisdall closed 10 years ago
Which extractor are you using? I can't replicate that output with lingua's python extractor:
$ mkdir tst
$ cat <<EOF > tst/x.py
_('Logout ${login}', mapping={'login':request.user.login})
EOF
$ pot-create tst
$ sed -ne '/^$/,$p' messages.pot
#: ./tst/x.py:1
#, python-format
msgid "Logout ${login}"
Could it be that you are trying to use Babel's Python extractor? That does not know how to handle the translationstring or zope.i18nmessageid format and is likely to incorrectly detect plural strings.
Sorry, I thought I should edit the post, but I was hoping you'd see the .mako
in the comments. It's using the babel-mako
parser. The tag in mako is simply ${_('Logout ${login}', mapping={'login':request.user.login})}
.
I just tried a .mako
file with only ${_('Logout ${login}', mapping={'login':'login'})}
in it and it had the same result.
Ah, I'm afraid there is little I can do about that: that is the Babel mako plugin using the Babel python plugin to handle any Python code it finds in mako files. The available options I see are:
_(...)
in mako files, but pass that in from our calling code.If @zzzeek is willing to accept a change for Mako to add a lingua extractor I'm willing to create that.
ah.. I thought Babel didn't do plural, though... It seems odd that it's improperly seeing string replacement as a plural thing.
Is there another way I can do string replacement without triggering it into thinking it's a "plural" translation? In that example I just want it to say "Logout [USERNAME]" where the username isn't translated.
I suspect Babel has a pretty simple concept of plural: any extra parameter for _(...)
is treated as a plural msgid. I can't think of a good way to handle this sanely through the Babel plugin. However: I just asked zzzeek and he is willing to accept a patch for Mako to add native lingua support. I'll try to get that in this week.
pot-create
generates the following from_('Logout ${login}', mapping={'login':request.user.login})
msginit
then chokes on that with the message: "mainserver.pot:172:10: syntax error" (172 is the "msgstr" line above)I'm not sure if this is a lingua or Babel issue, but it seems like it's incorrectly detecting the translation string as plural and then generating some .pot content that's not proper syntax. If I change line 172 to
msgstr[0] ""
the syntax error goes away, but obviously it's still not what I wanted.