summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2016-05-05 23:26:19 +0900
committershimizukawa <shimizukawa@gmail.com>2016-05-06 00:33:06 +0900
commit26fecafb4920a8d9dacaa9e3614bf182ce12696a (patch)
tree02c719996e3c8f68e28ff8825ec1f3b2c72aa637
parentd6572259d66cfb9da967f45fb2d671d29c5d5683 (diff)
downloadsphinx-git-26fecafb4920a8d9dacaa9e3614bf182ce12696a.tar.gz
fix #2522: Sphinx touches mo files under installed directory
that caused permission error.
-rw-r--r--CHANGES1
-rw-r--r--sphinx/application.py15
-rw-r--r--sphinx/locale/__init__.py9
-rw-r--r--sphinx/transforms.py4
4 files changed, 13 insertions, 16 deletions
diff --git a/CHANGES b/CHANGES
index 7c1692dbe..ab2bd65a1 100644
--- a/CHANGES
+++ b/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)
diff --git a/sphinx/application.py b/sphinx/application.py
index a833816f1..e82719d77 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -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
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index f7a375dec..d2d08c628 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -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:
diff --git a/sphinx/transforms.py b/sphinx/transforms.py
index 47e22237e..abeab7dab 100644
--- a/sphinx/transforms.py
+++ b/sphinx/transforms.py
@@ -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