From: Pedro Algarvio Date: Mon, 25 Jun 2007 11:37:01 +0000 (+0000) Subject: Fix for #28 with updated doctest. X-Git-Tag: 1.0~471 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc3aa3505093a17b5baec2341a32244fdc36d06a;p=thirdparty%2Fbabel.git Fix for #28 with updated doctest. --- diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py index c0921dc4..f1526175 100644 --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -35,6 +35,7 @@ def write_mo(fileobj, catalog, use_fuzzy=False): >>> catalog.add('foo', 'Voh') >>> catalog.add((u'bar', u'baz'), (u'Bahr', u'Batz')) >>> catalog.add('fuz', 'Futz', flags=['fuzzy']) + >>> catalog.add('Fizz', '') >>> buf = StringIO() >>> write_mo(buf, catalog) @@ -48,6 +49,8 @@ def write_mo(fileobj, catalog, use_fuzzy=False): u'Batz' >>> translations.ugettext('fuz') u'fuz' + >>> translations.ugettext('Fizz') + u'Fizz' :param fileobj: the file-like object to write to :param catalog: the `Catalog` instance @@ -74,7 +77,10 @@ def write_mo(fileobj, catalog, use_fuzzy=False): ]) else: msgid = message.id.encode(catalog.charset) - msgstr = message.string.encode(catalog.charset) + if not message.string: + msgstr = message.id.encode(catalog.charset) + else: + msgstr = message.string.encode(catalog.charset) offsets.append((len(ids), len(msgid), len(strs), len(msgstr))) ids += msgid + '\x00' strs += msgstr + '\x00'