diff options
author | Takayuki Shimizukawa <shimizukawa+bitbucket@gmail.com> | 2013-07-12 08:49:13 +0900 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa+bitbucket@gmail.com> | 2013-07-12 08:49:13 +0900 |
commit | e4131046cc746479ed5e64d740793269b2434a11 (patch) | |
tree | 5a689a0adddda130398ba160107f94a9f91e163b | |
parent | c50a0da03427bc346441e0637fb8da48b0325e3c (diff) | |
parent | d445011dd0e251fd8e43175a460663990ad9c27a (diff) | |
download | sphinx-e4131046cc746479ed5e64d740793269b2434a11.tar.gz |
Merged in ericholscher/sphinx (pull request #150)
A pull request with some developer documentation updates
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/util/nodes.py | 6 | ||||
-rw-r--r-- | tests/roots/test-intl/admonitions.po | 81 | ||||
-rw-r--r-- | tests/roots/test-intl/admonitions.txt | 46 | ||||
-rw-r--r-- | tests/test_intl.py | 14 |
5 files changed, 146 insertions, 2 deletions
@@ -39,6 +39,7 @@ Bugs fixed * #1176: Fix i18n: footnote reference number missing for auto numbered named footnote and auto symbol footnote. * PR#146,#1172: Fix ZeroDivisionError in Parallel Builds. Thanks to tychoish. +* #1206: Fix i18n: gettext did not translate admonition directive's title. Release 1.2 (beta1 released Mar 31, 2013) diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 62ad5d77..a8395f60 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -53,10 +53,12 @@ def extract_messages(doctree): node.line = definition_list_item.line - 1 node.rawsource = definition_list_item.\ rawsource.split("\n", 2)[0] - # workaround: nodes.caption doesn't have source, line. + # workaround: docutils-0.10.0 or older's nodes.caption for nodes.figure + # and nodes.title for nodes.admonition doesn't have source, line. # this issue was filed to Docutils tracker: # sf.net/tracker/?func=detail&aid=3599485&group_id=38414&atid=422032 - if isinstance(node, nodes.caption) and not node.source: + # sourceforge.net/p/docutils/patches/108/ + if isinstance(node, (nodes.caption, nodes.title)) and not node.source: node.source = node.parent.source node.line = 0 #need fix docutils to get `node.line` diff --git a/tests/roots/test-intl/admonitions.po b/tests/roots/test-intl/admonitions.po new file mode 100644 index 00000000..0dd16376 --- /dev/null +++ b/tests/roots/test-intl/admonitions.po @@ -0,0 +1,81 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2013, test_intl +# This file is distributed under the same license as the foo package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: sphinx 1.2\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-03 12:00\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 "Admonitions" +msgstr "ADMONITIONS" + +msgid "attention title" +msgstr "ATTENTION TITLE" + +msgid "attention body" +msgstr "ATTENTION BODY" + +msgid "caution title" +msgstr "CAUTION TITLE" + +msgid "caution body" +msgstr "CAUTION BODY" + +msgid "danger title" +msgstr "DANGER TITLE" + +msgid "danger body" +msgstr "DANGER BODY" + +msgid "error title" +msgstr "ERROR TITLE" + +msgid "error body" +msgstr "ERROR BODY" + +msgid "hint title" +msgstr "HINT TITLE" + +msgid "hint body" +msgstr "HINT BODY" + +msgid "important title" +msgstr "IMPORTANT TITLE" + +msgid "important body" +msgstr "IMPORTANT BODY" + +msgid "note title" +msgstr "NOTE TITLE" + +msgid "note body" +msgstr "NOTE BODY" + +msgid "tip title" +msgstr "TIP TITLE" + +msgid "tip body" +msgstr "TIP BODY" + +msgid "warning title" +msgstr "WARNING TITLE" + +msgid "warning body" +msgstr "WARNING BODY" + +msgid "admonition title" +msgstr "ADMONITION TITLE" + +msgid "admonition body" +msgstr "ADMONITION BODY" + diff --git a/tests/roots/test-intl/admonitions.txt b/tests/roots/test-intl/admonitions.txt new file mode 100644 index 00000000..170b8ed5 --- /dev/null +++ b/tests/roots/test-intl/admonitions.txt @@ -0,0 +1,46 @@ +:tocdepth: 2 + +Admonitions +================== +.. #1206 gettext did not translate admonition directive's title + +.. attention:: attention title + + attention body + +.. caution:: caution title + + caution body + +.. danger:: danger title + + danger body + +.. error:: error title + + error body + +.. hint:: hint title + + hint body + +.. important:: important title + + important body + +.. note:: note title + + note body + +.. tip:: tip title + + tip body + +.. warning:: warning title + + warning body + +.. admonition:: admonition title + + admonition body + diff --git a/tests/test_intl.py b/tests/test_intl.py index ef412c1d..67ab9578 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -593,6 +593,20 @@ def test_i18n_docfields(app): assert result == expect +@with_intl_app(buildername='text', cleanenv=True) +def test_i18n_admonitions(app): + # #1206: gettext did not translate admonition directive's title + # seealso: http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions + app.builder.build(['admonitions']) + result = (app.outdir / 'admonitions.txt').text(encoding='utf-8') + directives = ( + "attention", "caution", "danger", "error", "hint", + "important", "note", "tip", "warning", "admonition",) + for d in directives: + assert d.upper() + " TITLE" in result + assert d.upper() + " BODY" in result + + @with_intl_app(buildername='html', cleanenv=True) def test_i18n_docfields_html(app): app.builder.build(['docfields']) |