#418: Allow relocation of the translation JavaScript files to the system directory on Unix systems.

Patch by Toshio Kuratomi.
This commit is contained in:
Georg Brandl 2010-05-22 10:52:53 +02:00
parent cbf309fa65
commit be23bc91da
2 changed files with 22 additions and 9 deletions

View File

@ -1,6 +1,9 @@
Release 0.6.6 (in development) Release 0.6.6 (in development)
============================== ==============================
* #418: Allow relocation of the translation JavaScript files to
the system directory on Unix systems.
* #414: Fix handling of Windows newlines in files included with * #414: Fix handling of Windows newlines in files included with
the ``literalinclude`` directive. the ``literalinclude`` directive.

View File

@ -10,6 +10,7 @@
""" """
import os import os
import sys
import codecs import codecs
import posixpath import posixpath
import cPickle as pickle import cPickle as pickle
@ -91,10 +92,15 @@ class StandaloneHTMLBuilder(Builder):
self.link_suffix = self.out_suffix self.link_suffix = self.out_suffix
if self.config.language is not None: if self.config.language is not None:
jsfile = path.join(package_dir, 'locale', self.config.language, jsfile_list = [path.join(package_dir, 'locale',
'LC_MESSAGES', 'sphinx.js') self.config.language, 'LC_MESSAGES', 'sphinx.js'),
if path.isfile(jsfile): path.join(sys.prefix, 'share/sphinx/locale',
self.script_files.append('_static/translations.js') self.config.language, 'sphinx.js')]
for jsfile in jsfile_list:
if path.isfile(jsfile):
self.script_files.append('_static/translations.js')
break
def init_templates(self): def init_templates(self):
Theme.init_themes(self) Theme.init_themes(self)
@ -530,11 +536,15 @@ class StandaloneHTMLBuilder(Builder):
f.close() f.close()
# then, copy translations JavaScript file # then, copy translations JavaScript file
if self.config.language is not None: if self.config.language is not None:
jsfile = path.join(package_dir, 'locale', self.config.language, jsfile_list = [path.join(package_dir, 'locale',
'LC_MESSAGES', 'sphinx.js') self.config.language, 'LC_MESSAGES', 'sphinx.js'),
if path.isfile(jsfile): path.join(sys.prefix, 'share/sphinx/locale',
copyfile(jsfile, path.join(self.outdir, '_static', self.config.language, 'sphinx.js')]
'translations.js')) for jsfile in jsfile_list:
if path.isfile(jsfile):
copyfile(jsfile, path.join(self.outdir, '_static',
'translations.js'))
break
# then, copy over all user-supplied static files # then, copy over all user-supplied static files
if self.theme: if self.theme:
staticdirnames = [path.join(themepath, 'static') staticdirnames = [path.join(themepath, 'static')