mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
i18n: Fix loading custom template translations for en (#12220)
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
This commit is contained in:
parent
71d50a8658
commit
18d30343f2
@ -271,29 +271,26 @@ class Sphinx:
|
||||
"""Load translated strings from the configured localedirs if enabled in
|
||||
the configuration.
|
||||
"""
|
||||
if self.config.language == 'en':
|
||||
self.translator, _ = locale.init([], None)
|
||||
logger.info(bold(__('loading translations [%s]... ')), self.config.language,
|
||||
nonl=True)
|
||||
|
||||
# compile mo files if sphinx.po file in user locale directories are updated
|
||||
repo = CatalogRepository(self.srcdir, self.config.locale_dirs,
|
||||
self.config.language, self.config.source_encoding)
|
||||
for catalog in repo.catalogs:
|
||||
if catalog.domain == 'sphinx' and catalog.is_outdated():
|
||||
catalog.write_mo(self.config.language,
|
||||
self.config.gettext_allow_fuzzy_translations)
|
||||
|
||||
locale_dirs: list[str | None] = list(repo.locale_dirs)
|
||||
locale_dirs += [None]
|
||||
locale_dirs += [path.join(package_dir, 'locale')]
|
||||
|
||||
self.translator, has_translation = locale.init(locale_dirs, self.config.language)
|
||||
if has_translation or self.config.language == 'en':
|
||||
logger.info(__('done'))
|
||||
else:
|
||||
logger.info(bold(__('loading translations [%s]... ')), self.config.language,
|
||||
nonl=True)
|
||||
|
||||
# compile mo files if sphinx.po file in user locale directories are updated
|
||||
repo = CatalogRepository(self.srcdir, self.config.locale_dirs,
|
||||
self.config.language, self.config.source_encoding)
|
||||
for catalog in repo.catalogs:
|
||||
if catalog.domain == 'sphinx' and catalog.is_outdated():
|
||||
catalog.write_mo(self.config.language,
|
||||
self.config.gettext_allow_fuzzy_translations)
|
||||
|
||||
locale_dirs: list[str | None] = list(repo.locale_dirs)
|
||||
locale_dirs += [None]
|
||||
locale_dirs += [path.join(package_dir, 'locale')]
|
||||
|
||||
self.translator, has_translation = locale.init(locale_dirs, self.config.language)
|
||||
if has_translation:
|
||||
logger.info(__('done'))
|
||||
else:
|
||||
logger.info(__('not available for built-in messages'))
|
||||
logger.info(__('not available for built-in messages'))
|
||||
|
||||
def _init_env(self, freshenv: bool) -> BuildEnvironment:
|
||||
filename = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
|
||||
|
Loading…
Reference in New Issue
Block a user