mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
fix #2522: Sphinx touches mo files under installed directory
that caused permission error.
This commit is contained in:
parent
d6572259d6
commit
26fecafb49
1
CHANGES
1
CHANGES
@ -52,6 +52,7 @@ Bugs fixed
|
||||
* #2492: Figure directive with :figwidth: generates incorrect Latex-code
|
||||
* The caption of figure is always put on center even if ``:align:`` was specified
|
||||
* #2526: LaTeX writer crashes if the section having only images
|
||||
* #2522: Sphinx touches mo files under installed directory that caused permission error.
|
||||
|
||||
|
||||
Release 1.4.1 (released Apr 12, 2016)
|
||||
|
@ -44,6 +44,7 @@ from sphinx.util.osutil import ENOENT
|
||||
from sphinx.util.logging import is_suppressed_warning
|
||||
from sphinx.util.console import bold, lightgray, darkgray, darkgreen, \
|
||||
term_width_line
|
||||
from sphinx.util.i18n import find_catalog_source_files
|
||||
|
||||
if hasattr(sys, 'intern'):
|
||||
intern = sys.intern
|
||||
@ -207,13 +208,17 @@ class Sphinx(object):
|
||||
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]
|
||||
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,
|
||||
charset=self.config.source_encoding)
|
||||
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
|
||||
|
@ -195,7 +195,7 @@ else:
|
||||
return translators['sphinx'].ugettext(message)
|
||||
|
||||
|
||||
def init(locale_dirs, language, catalog='sphinx', charset='utf-8'):
|
||||
def init(locale_dirs, language, catalog='sphinx'):
|
||||
"""Look for message catalogs in `locale_dirs` and *ensure* that there is at
|
||||
least a NullTranslations catalog set in `translators`. If called multiple
|
||||
times or if several ``.mo`` files are found, their contents are merged
|
||||
@ -209,13 +209,6 @@ def init(locale_dirs, language, catalog='sphinx', charset='utf-8'):
|
||||
# the None entry is the system's default locale path
|
||||
has_translation = True
|
||||
|
||||
# compile mo files if po file is updated
|
||||
# TODO: remove circular importing
|
||||
from sphinx.util.i18n import find_catalog_source_files
|
||||
for catinfo in find_catalog_source_files(locale_dirs, language, domains=[catalog],
|
||||
charset=charset):
|
||||
catinfo.write_mo(language)
|
||||
|
||||
# loading
|
||||
for dir_ in locale_dirs:
|
||||
try:
|
||||
|
@ -239,9 +239,7 @@ class Locale(Transform):
|
||||
# fetch translations
|
||||
dirs = [path.join(env.srcdir, directory)
|
||||
for directory in env.config.locale_dirs]
|
||||
catalog, has_catalog = init_locale(dirs, env.config.language,
|
||||
textdomain,
|
||||
charset=env.config.source_encoding)
|
||||
catalog, has_catalog = init_locale(dirs, env.config.language, textdomain)
|
||||
if not has_catalog:
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user