[Checkins] SVN: zope.app.locales/trunk/ i18nextract bugfix: _("msgid", mapping=...) does not have a default.
Marius Gedminas
marius at pov.lt
Fri Jan 6 19:07:10 UTC 2012
Log message for revision 123970:
i18nextract bugfix: _("msgid", mapping=...) does not have a default.
Changed:
U zope.app.locales/trunk/CHANGES.txt
U zope.app.locales/trunk/src/zope/app/locales/extract.py
-=-
Modified: zope.app.locales/trunk/CHANGES.txt
===================================================================
--- zope.app.locales/trunk/CHANGES.txt 2012-01-06 17:20:44 UTC (rev 123969)
+++ zope.app.locales/trunk/CHANGES.txt 2012-01-06 19:07:09 UTC (rev 123970)
@@ -5,7 +5,9 @@
3.7.3 (unreleased)
------------------
-- Nothing changed yet.
+- i18nextract bugfix: _("msgid", mapping={...}) does not have a default, just
+ like _("msgid"). Previously it would get a ``#. Default: ""`` annotation in
+ the .pot file.
3.7.2 (2011-12-12)
Modified: zope.app.locales/trunk/src/zope/app/locales/extract.py
===================================================================
--- zope.app.locales/trunk/src/zope/app/locales/extract.py 2012-01-06 17:20:44 UTC (rev 123969)
+++ zope.app.locales/trunk/src/zope/app/locales/extract.py 2012-01-06 19:07:09 UTC (rev 123970)
@@ -213,7 +213,9 @@
>>> file = StringIO(
... "_(u'hello ${name}', u'buenos dias', {'name': 'Bob'}); "
- ... "_(u'hi ${name}', mapping={'name': 'Bob'})"
+ ... "_(u'hi ${name}', mapping={'name': 'Bob'}); "
+ ... "_('k, bye', ''); "
+ ... "_('kthxbye')"
... )
>>> tokenize.tokenize(file.readline, eater)
@@ -223,7 +225,10 @@
>>> items = catalog.items()
>>> items.sort()
>>> items
- [(u'hello ${name}', [(None, 1)]), (u'hi ${name}', [(None, 1)])]
+ [(u'hello ${name}', [(None, 1)]),
+ (u'hi ${name}', [(None, 1)]),
+ (u'k, bye', [(None, 1)]),
+ (u'kthxbye', [(None, 1)])]
The key in the catalog is not a unicode string, it's a real
message id with a default value:
@@ -238,8 +243,18 @@
>>> msgid
u'hi ${name}'
>>> msgid.default
+
+ >>> msgid = items.pop(0)[0]
+ >>> msgid
+ u'k, bye'
+ >>> msgid.default
u''
+ >>> msgid = items.pop(0)[0]
+ >>> msgid
+ u'kthxbye'
+ >>> msgid.default
+
Note that everything gets converted to unicode.
"""
implements(ITokenEater)
@@ -278,7 +293,7 @@
if ttype == tokenize.OP and tstring == '(':
self.__data = []
self.__msgid = ''
- self.__default = ''
+ self.__default = None
self.__lineno = lineno
self.__state = self.__openseen
else:
@@ -297,7 +312,10 @@
default = self.__default
elif self.__msgid:
msgid = self.__msgid
- default = ''.join(self.__data)
+ if self.__data:
+ default = ''.join(self.__data)
+ else:
+ default = None
else:
msgid = ''.join(self.__data)
default = None
@@ -306,7 +324,7 @@
elif ttype == tokenize.OP and tstring == ',':
if not self.__msgid:
self.__msgid = ''.join(self.__data)
- elif not self.__default:
+ elif not self.__default and self.__data:
self.__default = ''.join(self.__data)
self.__data = []
elif ttype == tokenize.STRING:
More information about the checkins
mailing list