# 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
        )
        user_locale_dirs = [path.join(self.srcdir, x) for x in self.config.locale_dirs]
        # compile mo files if sphinx.po file in user locale directories are updated
        for catinfo in find_catalog_source_files(
            user_locale_dirs,
            self.config.language,
            domains=["sphinx"],
            charset=self.config.source_encoding,
        ):
            catinfo.write_mo(self.config.language)
        locale_dirs = [None, path.join(package_dir, "locale")] + user_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 (IndexError)
# Sphinx version: 1.5.1
# Python version: 2.7.9 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.3
# Last messages:
#   Running Sphinx v1.5.1
#   making output directory...
#   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%] locale/ja/LC_MESSAGES/index.mo
# Loaded extensions:
#   sphinx.domains.cpp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/cpp.pyc
#   sphinx.builders.applehelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/applehelp.pyc
#   sphinx.directives (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/__init__.pyc
#   sphinx.builders.changes (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/changes.pyc
#   sphinx.builders.websupport (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/websupport.pyc
#   sphinx.domains.c (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/c.pyc
#   sphinx.builders.dummy (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/dummy.pyc
#   sphinx.builders.texinfo (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/texinfo.pyc
#   sphinx.builders.epub (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/epub.pyc
#   sphinx.builders.linkcheck (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyc
#   sphinx.domains.std (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/std.pyc
#   sphinx.directives.other (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/other.pyc
#   sphinx.builders.epub3 (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/epub3.pyc
#   sphinx.domains.javascript (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/javascript.pyc
#   sphinx.directives.code (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/code.pyc
#   alabaster (0.7.9) from /usr/local/lib/python2.7/site-packages/alabaster/__init__.pyc
#   sphinx.builders.text (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/text.pyc
#   sphinx.builders.qthelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/qthelp.pyc
#   sphinx.roles (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/roles.pyc
#   sphinx.builders.htmlhelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyc
#   sphinx.directives.patches (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/patches.pyc
#   sphinx.builders.latex (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/latex.pyc
#   sphinx.builders.html (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/html.pyc
#   sphinx.builders.devhelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/devhelp.pyc
#   sphinx.builders.gettext (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/gettext.pyc
#   sphinx.builders.xml (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/xml.pyc
#   sphinx.builders.manpage (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/manpage.pyc
#   sphinx.domains.rst (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/rst.pyc
#   sphinx.domains.python (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/python.pyc
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 296, in main
app.build(opts.force_all, filenames)
File "/usr/local/lib/python2.7/site-packages/sphinx/application.py", line 332, in build
self.builder.compile_update_catalogs()
File "/usr/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 205, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "/usr/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 170, in compile_catalogs
catalog.write_mo(self.config.language)
File "/usr/local/lib/python2.7/site-packages/sphinx/util/i18n.py", line 59, in write_mo
write_mo(mo, read_po(po, locale))
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 244, in read_po
_process_message_line(lineno, line)
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 186, in _process_message_line
_add_message()
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 153, in _add_message
string = denormalize(translations[0][1])
IndexError: list index out of range

# 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
        )
        user_locale_dirs = [path.join(self.srcdir, x) for x in self.config.locale_dirs]
        # compile mo files if sphinx.po file in user locale directories are updated
        for catinfo in find_catalog_source_files(
            user_locale_dirs,
            self.config.language,
            domains=["sphinx"],
            charset=self.config.source_encoding,
        ):
            catinfo.write_mo(self.config.language, self.warn)
        locale_dirs = [None, path.join(package_dir, "locale")] + user_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")