1. Marijn van der Zee
  2. sphinx

Commits

Georg Brandl  committed e1af004

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

  • Participants
  • Parent commits 12fea70
  • Branches default

Comments (0)

Files changed (2)

File CHANGES

View file
 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
   the ``literalinclude`` directive.
 

File sphinx/builders/html.py

View file
 """
 
 import os
+import sys
 import codecs
 import posixpath
 import cPickle as pickle
             self.link_suffix = self.out_suffix
 
         if self.config.language is not None:
-            jsfile = path.join(package_dir, 'locale', self.config.language,
-                               'LC_MESSAGES', 'sphinx.js')
-            if path.isfile(jsfile):
-                self.script_files.append('_static/translations.js')
+            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
 
     def init_templates(self):
         Theme.init_themes(self)
         f.close()
         # then, copy translations JavaScript file
         if self.config.language is not None:
-            jsfile = path.join(package_dir, 'locale', self.config.language,
-                               'LC_MESSAGES', 'sphinx.js')
-            if path.isfile(jsfile):
-                copyfile(jsfile, path.join(self.outdir, '_static',
-                                           'translations.js'))
+            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
         # then, copy over all user-supplied static files
         if self.theme:
             staticdirnames = [path.join(themepath, 'static')