mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
make versionmodified translatable
This commit is contained in:
parent
919ba75483
commit
81d21a7714
@ -194,12 +194,20 @@ class VersionChange(Directive):
|
|||||||
if len(self.arguments) == 2:
|
if len(self.arguments) == 2:
|
||||||
inodes, messages = self.state.inline_text(self.arguments[1],
|
inodes, messages = self.state.inline_text(self.arguments[1],
|
||||||
self.lineno+1)
|
self.lineno+1)
|
||||||
node.append(nodes.paragraph('', '', *inodes))
|
para = nodes.paragraph(self.arguments[1], '', *inodes)
|
||||||
|
set_source_info(self, para)
|
||||||
|
node.append(para)
|
||||||
else:
|
else:
|
||||||
messages = []
|
messages = []
|
||||||
if self.content:
|
if self.content:
|
||||||
self.state.nested_parse(self.content, self.content_offset, node)
|
self.state.nested_parse(self.content, self.content_offset, node)
|
||||||
if len(node):
|
if len(node):
|
||||||
|
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
|
||||||
|
content = nodes.inline(node[0].rawsource, translatable=True)
|
||||||
|
content.source = node[0].source
|
||||||
|
content.line = node[0].line
|
||||||
|
content += node[0].children
|
||||||
|
node[0].replace_self(nodes.paragraph('', '', content))
|
||||||
node[0].insert(0, nodes.inline('', '%s: ' % text))
|
node[0].insert(0, nodes.inline('', '%s: ' % text))
|
||||||
else:
|
else:
|
||||||
para = nodes.paragraph('', '', nodes.inline('', '%s.' % text))
|
para = nodes.paragraph('', '', nodes.inline('', '%s.' % text))
|
||||||
|
@ -19,4 +19,5 @@ CONTENTS
|
|||||||
role_xref
|
role_xref
|
||||||
glossary_terms
|
glossary_terms
|
||||||
glossary_terms_inconsistency
|
glossary_terms_inconsistency
|
||||||
|
versionchange
|
||||||
docfields
|
docfields
|
||||||
|
33
tests/roots/test-intl/versionchange.po
Normal file
33
tests/roots/test-intl/versionchange.po
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) 2010, Georg Brandl & Team
|
||||||
|
# This file is distributed under the same license as the Sphinx <Tests> package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: sphinx 1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2012-12-15 03:17\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
msgid "i18n with versionchange"
|
||||||
|
msgstr "I18N WITH VERSIONCHANGE"
|
||||||
|
|
||||||
|
msgid "This is the *first* paragraph of deprecated."
|
||||||
|
msgstr "THIS IS THE *FIRST* PARAGRAPH OF DEPRECATED."
|
||||||
|
|
||||||
|
msgid "This is the *second* paragraph of deprecated."
|
||||||
|
msgstr "THIS IS THE *SECOND* PARAGRAPH OF DEPRECATED."
|
||||||
|
|
||||||
|
msgid "This is the *first* paragraph of versionadded."
|
||||||
|
msgstr "THIS IS THE *FIRST* PARAGRAPH OF VERSIONADDED."
|
||||||
|
|
||||||
|
msgid "This is the *first* paragraph of versionchanged."
|
||||||
|
msgstr "THIS IS THE *FIRST* PARAGRAPH OF VERSIONCHANGED."
|
||||||
|
|
16
tests/roots/test-intl/versionchange.txt
Normal file
16
tests/roots/test-intl/versionchange.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
:tocdepth: 2
|
||||||
|
|
||||||
|
i18n with versionchange
|
||||||
|
============================
|
||||||
|
|
||||||
|
.. deprecated:: 1.0
|
||||||
|
This is the *first* paragraph of deprecated.
|
||||||
|
|
||||||
|
This is the *second* paragraph of deprecated.
|
||||||
|
|
||||||
|
.. versionadded:: 1.0
|
||||||
|
This is the *first* paragraph of versionadded.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.0
|
||||||
|
|
||||||
|
This is the *first* paragraph of versionchanged.
|
@ -389,6 +389,39 @@ def test_i18n_index_entries(app):
|
|||||||
assert re.search(expr, result, re.M)
|
assert re.search(expr, result, re.M)
|
||||||
|
|
||||||
|
|
||||||
|
@with_intl_app(buildername='html', cleanenv=True)
|
||||||
|
def test_versionchange(app):
|
||||||
|
app.builder.build(['versionchange'])
|
||||||
|
result = (app.outdir / 'versionchange.html').text(encoding='utf-8')
|
||||||
|
|
||||||
|
def get_content(result, name):
|
||||||
|
matched = re.search(r'<div class="%s">\n*(.*?)</div>' % name,
|
||||||
|
result, re.DOTALL)
|
||||||
|
if matched:
|
||||||
|
return matched.group(1)
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
expect1 = (
|
||||||
|
u"""<p><span>Deprecated since version 1.0: </span>"""
|
||||||
|
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF DEPRECATED.</p>\n"""
|
||||||
|
u"""<p>THIS IS THE <em>SECOND</em> PARAGRAPH OF DEPRECATED.</p>\n""")
|
||||||
|
matched_content = get_content(result, "deprecated")
|
||||||
|
assert expect1 == matched_content
|
||||||
|
|
||||||
|
expect2 = (
|
||||||
|
u"""<p><span>New in version 1.0: </span>"""
|
||||||
|
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONADDED.</p>\n""")
|
||||||
|
matched_content = get_content(result, "versionadded")
|
||||||
|
assert expect2 == matched_content
|
||||||
|
|
||||||
|
expect3 = (
|
||||||
|
u"""<p><span>Changed in version 1.0: </span>"""
|
||||||
|
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONCHANGED.</p>\n""")
|
||||||
|
matched_content = get_content(result, "versionchanged")
|
||||||
|
assert expect3 == matched_content
|
||||||
|
|
||||||
|
|
||||||
@with_intl_app(buildername='text', cleanenv=True)
|
@with_intl_app(buildername='text', cleanenv=True)
|
||||||
def test_i18n_docfields(app):
|
def test_i18n_docfields(app):
|
||||||
app.builder.build(['docfields'])
|
app.builder.build(['docfields'])
|
||||||
|
Loading…
Reference in New Issue
Block a user