summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-04 09:34:44 +0100
committerGeorg Brandl <georg@python.org>2011-01-04 09:34:44 +0100
commitfead912b0a78ff95c04311625b7bc891b6aeb8ca (patch)
tree0ee1f553fc3e639f5d4b63beda611277ff1e09c1
parent77a016a404d48cc44026d0bec691e967e92e58bf (diff)
downloadsphinx-fead912b0a78ff95c04311625b7bc891b6aeb8ca.tar.gz
#528: Observe :confval:`locale_dirs` when looking for the JS translations file.
-rw-r--r--CHANGES3
-rw-r--r--sphinx/builders/html.py37
2 files changed, 22 insertions, 18 deletions
diff --git a/CHANGES b/CHANGES
index ec30df93..7e4de2d2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
Release 1.0.6 (in development)
==============================
+* #528: Observe :confval:`locale_dirs` when looking for the JS
+ translations file.
+
* #574: Add special code for better support of Japanese documents
in the LaTeX builder.
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index cab12afa..d0867bb5 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -102,15 +102,21 @@ class StandaloneHTMLBuilder(Builder):
self.link_suffix = self.out_suffix
if self.config.language is not None:
- jsfile_list = [path.join(package_dir, 'locale',
- self.config.language, 'LC_MESSAGES', 'sphinx.js'),
- path.join(sys.prefix, 'share/sphinx/locale',
- self.config.language, 'sphinx.js')]
-
- for jsfile in jsfile_list:
- if path.isfile(jsfile):
- self.script_files.append('_static/translations.js')
- break
+ if self._get_translations_js():
+ self.script_files.append('_static/translations.js')
+
+ def _get_translations_js(self):
+ candidates = [path.join(package_dir, 'locale', self.config.language,
+ 'LC_MESSAGES', 'sphinx.js'),
+ path.join(sys.prefix, 'share/sphinx/locale',
+ self.config.language, 'sphinx.js')] + \
+ [path.join(dir, self.config.language,
+ 'LC_MESSAGES', 'sphinx.js')
+ for dir in self.config.locale_dirs]
+ for jsfile in candidates:
+ if path.isfile(jsfile):
+ return jsfile
+ return None
def get_theme_config(self):
return self.config.html_theme, self.config.html_theme_options
@@ -526,15 +532,10 @@ class StandaloneHTMLBuilder(Builder):
f.close()
# then, copy translations JavaScript file
if self.config.language is not None:
- jsfile_list = [path.join(package_dir, 'locale',
- self.config.language, 'LC_MESSAGES', 'sphinx.js'),
- path.join(sys.prefix, 'share/sphinx/locale',
- self.config.language, 'sphinx.js')]
- for jsfile in jsfile_list:
- if path.isfile(jsfile):
- copyfile(jsfile, path.join(self.outdir, '_static',
- 'translations.js'))
- break
+ jsfile = self._get_translations_js()
+ if jsfile:
+ copyfile(jsfile, path.join(self.outdir, '_static',
+ 'translations.js'))
# then, copy over theme-supplied static files
if self.theme:
themeentries = [path.join(themepath, 'static')