mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2074 from techtonik/patch-1
gettext: use canonical relative paths for .pot
This commit is contained in:
commit
07c10e540f
@ -23,7 +23,7 @@ from six import iteritems
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.util import split_index_msg
|
||||
from sphinx.util.nodes import extract_messages, traverse_translatable_index
|
||||
from sphinx.util.osutil import safe_relpath, ensuredir, SEP
|
||||
from sphinx.util.osutil import safe_relpath, ensuredir, canon_path
|
||||
from sphinx.util.i18n import find_catalog
|
||||
from sphinx.util.console import darkgreen, purple, bold
|
||||
from sphinx.locale import pairindextypes
|
||||
@ -165,8 +165,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
for dirpath, dirs, files in walk(tmpl_abs_path):
|
||||
for fn in files:
|
||||
if fn.endswith('.html'):
|
||||
filename = path.join(dirpath, fn)
|
||||
filename = filename.replace(path.sep, SEP)
|
||||
filename = canon_path(path.join(dirpath, fn))
|
||||
template_files.add(filename)
|
||||
return template_files
|
||||
|
||||
@ -216,7 +215,8 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
if self.config.gettext_location:
|
||||
# generate "#: file1:line1\n#: file2:line2 ..."
|
||||
pofile.write("#: %s\n" % "\n#: ".join(
|
||||
"%s:%s" % (safe_relpath(source, self.outdir), line)
|
||||
"%s:%s" % (canon_path(
|
||||
safe_relpath(source, self.outdir)), line)
|
||||
for source, line, _ in positions))
|
||||
if self.config.gettext_uuid:
|
||||
# generate "# uuid1\n# uuid2\n ..."
|
||||
|
@ -40,6 +40,11 @@ def os_path(canonicalpath):
|
||||
return canonicalpath.replace(SEP, path.sep)
|
||||
|
||||
|
||||
def canon_path(nativepath):
|
||||
"""Return path in OS-independent form"""
|
||||
return nativepath.replace(path.sep, SEP)
|
||||
|
||||
|
||||
def relative_uri(base, to):
|
||||
"""Return a relative URL from ``base`` to ``to``."""
|
||||
if to.startswith(SEP):
|
||||
|
Loading…
Reference in New Issue
Block a user