[Checkins] SVN: zope.app.locales/trunk/ In version 3.7.2 msgids and default values where forced to be unicodes. This
Michael Howitz
cvs-admin at zope.org
Mon May 14 12:13:52 UTC 2012
Log message for revision 125861:
In version 3.7.2 msgids and default values where forced to be unicodes. This
was too strict because at least the TAL extractor returns UTF-8 encoded
default values. Fixed this by allowing the default value to be a string
again.
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-05-14 08:50:08 UTC (rev 125860)
+++ zope.app.locales/trunk/CHANGES.txt 2012-05-14 12:13:47 UTC (rev 125861)
@@ -5,6 +5,10 @@
3.7.4 (unreleased)
------------------
+- In version 3.7.2 msgids and default values where forced to be
+ unicodes. This was too strict because at least the TAL extractor returns
+ UTF-8 encoded default values. Fixed this by allowing the default value to
+ be a string again.
3.7.3 (2012-01-06)
Modified: zope.app.locales/trunk/src/zope/app/locales/extract.py
===================================================================
--- zope.app.locales/trunk/src/zope/app/locales/extract.py 2012-05-14 08:50:08 UTC (rev 125860)
+++ zope.app.locales/trunk/src/zope/app/locales/extract.py 2012-05-14 12:13:47 UTC (rev 125861)
@@ -97,7 +97,7 @@
msgstr ""
<BLANKLINE>
- Unicode can be used in msgids and default values
+ Unicode can be used in msgids and default values:
>>> entry = POTEntry(Message(u"\u263B", default=u"\u253A"))
>>> entry.write(FakeFile())
@@ -106,6 +106,16 @@
msgstr ""
<BLANKLINE>
+ But msgid might be an ascii encoded string and `default` might be a
+ string with the DEFAULT_ENCODING, too:
+
+ >>> entry = POTEntry(Message("Oe", default="\xd6"))
+ >>> entry.write(FakeFile())
+ #. Default: "\326"
+ msgid "Oe"
+ msgstr ""
+ <BLANKLINE>
+
"""
implements(IPOTEntry)
@@ -130,7 +140,9 @@
file.write('#: %s:%s\n' % (filename, line))
if (isinstance(self.msgid, Message) and
self.msgid.default is not None):
- default = self.msgid.default.strip().encode(DEFAULT_CHARSET)
+ default = self.msgid.default.strip()
+ if isinstance(default, unicode):
+ default = default.encode(DEFAULT_CHARSET)
lines = normalize(default).split("\n")
lines[0] = "#. Default: %s\n" % lines[0]
for i in range(1, len(lines)):
@@ -181,7 +193,7 @@
def write(self):
file = open(self._output_filename, 'w')
- file.write(pot_header % {'time': time.ctime(),
+ file.write(pot_header % {'time': time.ctime(),
'version': self._getProductVersion(),
'charset': DEFAULT_CHARSET,
'encoding': DEFAULT_ENCODING})
More information about the checkins
mailing list