[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/locales/extract.py
Now multiline default values generate correct comments in POT file
Dmitry Vasiliev
dima at hlabs.spb.ru
Thu Mar 24 09:49:11 EST 2005
Log message for revision 29666:
Now multiline default values generate correct comments in POT file
Changed:
U Zope3/trunk/src/zope/app/locales/extract.py
-=-
Modified: Zope3/trunk/src/zope/app/locales/extract.py
===================================================================
--- Zope3/trunk/src/zope/app/locales/extract.py 2005-03-24 09:40:35 UTC (rev 29665)
+++ Zope3/trunk/src/zope/app/locales/extract.py 2005-03-24 14:49:11 UTC (rev 29666)
@@ -61,7 +61,7 @@
'''
class POTEntry(object):
- """This class represents a single message entry in the POT file.
+ r"""This class represents a single message entry in the POT file.
>>> make_escapes(0)
>>> class FakeFile(object):
@@ -83,6 +83,17 @@
msgid "test"
msgstr ""
<BLANKLINE>
+
+ Multiline default values generate correct comments:
+
+ >>> entry = POTEntry(MessageID("test", default="\nline1\n\tline2"))
+ >>> entry.write(FakeFile())
+ # Default: ""
+ # "line1\n"
+ # "\tline2"
+ msgid "test"
+ msgstr ""
+ <BLANKLINE>
"""
implements(IPOTEntry)
@@ -99,11 +110,16 @@
filename.replace(os.sep, '/'), line)
def write(self, file):
- file.write(self.comments)
+ if self.comments:
+ file.write(self.comments)
if (isinstance(self.msgid, MessageID) and
self.msgid != self.msgid.default):
default = self.msgid.default.strip()
- file.write('# Default: %s\n' % normalize(default))
+ lines = normalize(default).split("\n")
+ lines[0] = "# Default: %s\n" % lines[0]
+ for i in range(1, len(lines)):
+ lines[i] = "# %s\n" % lines[i]
+ file.write("".join(lines))
file.write('msgid %s\n' % normalize(self.msgid))
file.write('msgstr ""\n')
file.write('\n')
More information about the Zope3-Checkins
mailing list