translation.py 632 B

123456789101112131415161718
  1. import sys
  2. import codecs
  3. # we do this first, since BitTorrent/__init__.py installs a stderr proxy.
  4. # py2exe'd Blackholes don't have encoding
  5. encoding = getattr(sys.stdout, "encoding", None)
  6. # and sometimes encoding is None anyway
  7. if encoding is not None:
  8. stdout_writer = codecs.getwriter(encoding)
  9. # don't fail if we can't write a value in the sydout encoding
  10. sys.stdout = stdout_writer(sys.stdout, 'replace')
  11. stderr_writer = codecs.getwriter(encoding)
  12. sys.stderr = stderr_writer(sys.stderr, 'replace')
  13. from BitTorrent.platform import install_translation
  14. install_translation(unicode=True)
  15. _ = _ # not a typo