Mercurial > babel > old > mirror
comparison babel/messages/pofile.py @ 549:12d5425fb430
babel.messages.pofile should only apply encoding when actually writing a file (eases Python 3 transition, closes #251)
author | fschwarz |
---|---|
date | Sat, 19 Mar 2011 19:50:21 +0000 |
parents | 10de195cfb04 |
children |
comparison
equal
deleted
inserted
replaced
548:dde86441b508 | 549:12d5425fb430 |
---|---|
380 comments | 380 comments |
381 :param include_previous: include the old msgid as a comment when | 381 :param include_previous: include the old msgid as a comment when |
382 updating the catalog | 382 updating the catalog |
383 """ | 383 """ |
384 def _normalize(key, prefix=''): | 384 def _normalize(key, prefix=''): |
385 return normalize(key, prefix=prefix, width=width) \ | 385 return normalize(key, prefix=prefix, width=width) |
386 .encode(catalog.charset, 'backslashreplace') | |
387 | 386 |
388 def _write(text): | 387 def _write(text): |
389 if isinstance(text, unicode): | 388 if isinstance(text, unicode): |
390 text = text.encode(catalog.charset) | 389 text = text.encode(catalog.charset, 'backslashreplace') |
391 fileobj.write(text) | 390 fileobj.write(text) |
392 | 391 |
393 def _write_comment(comment, prefix=''): | 392 def _write_comment(comment, prefix=''): |
394 # xgettext always wraps comments even if --no-wrap is passed; | 393 # xgettext always wraps comments even if --no-wrap is passed; |
395 # provide the same behaviour | 394 # provide the same behaviour |