Mercurial > babel > mirror
changeset 172:208c7dfb9041 trunk
Fix for #28 with updated doctest.
author | palgarvio |
---|---|
date | Mon, 25 Jun 2007 11:37:01 +0000 |
parents | 8780824d85f5 |
children | c100331c727c |
files | babel/messages/mofile.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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'