# HG changeset patch # User palgarvio # Date 1182771421 0 # Node ID 9e35bbb458aaf4b3e84df3b9afd7ba28788cf15d # Parent 0628c0450e6234d165a6d96938d3320410bb3794 Fix for #28 with updated doctest. diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -35,6 +35,7 @@ >>> 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 @@ 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 @@ ]) 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'