# Buggy code
def _init_i18n(self):
    """Load translated strings from the configured localedirs if enabled in
    the configuration.
    """
    if self.config.language is not None:
        self.info(
            bold("loading translations [%s]... " % self.config.language), nonl=True
        )
        locale_dirs = [None, path.join(package_dir, "locale")] + [
            path.join(self.srcdir, x) for x in self.config.locale_dirs
        ]
    else:
        locale_dirs = []
    self.translator, has_translation = locale.init(locale_dirs, self.config.language)
    if self.config.language is not None:
        if has_translation or self.config.language == "en":
            # "en" never needs to be translated
            self.info("done")
        else:
            self.info("not available for built-in messages")


# Traceback (UnicodeDecodeError)
D:\test>set SPHINXOPTS=-T

D:\test>make.bat html
Running Sphinx v1.3.1
loading translations [ja]... done
loading pickled environment... not yet created
building [mo]: targets for 1 po files that are out of date
writing output... [100%] D:\test\locale\ja\LC_MESSAGES\index.mo
Traceback (most recent call last):
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 263, in build
self.builder.compile_update_catalogs()
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 199, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 167, in compile_catalogs
catalog.write_mo(self.config.language)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\util\i18n.py", line 51, in write_mo
write_mo(mo, read_po(po, locale))
File "C:\Develop\pytools\sphinx-13\lib\site-packages\babel\messages\pofile.py", line 204, in read_po
for lineno, line in enumerate(fileobj.readlines()):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence

Encoding error:
'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence
The full traceback has been saved in D:\Temp\sphinx-err-8vfmzqmf.log, if you want to report the issue to the developers.

# Fixed code
def _init_i18n(self):
    """Load translated strings from the configured localedirs if enabled in
    the configuration.
    """
    if self.config.language is not None:
        self.info(
            bold("loading translations [%s]... " % self.config.language), nonl=True
        )
        locale_dirs = [None, path.join(package_dir, "locale")] + [
            path.join(self.srcdir, x) for x in self.config.locale_dirs
        ]
    else:
        locale_dirs = []
    self.translator, has_translation = locale.init(
        locale_dirs, self.config.language, charset=self.config.source_encoding
    )
    if self.config.language is not None:
        if has_translation or self.config.language == "en":
            # "en" never needs to be translated
            self.info("done")
        else:
            self.info("not available for built-in messages")