mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix i18n: gettext did not translate admonition directive's title. Closes #1206
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -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)
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
81
tests/roots/test-intl/admonitions.po
Normal file
81
tests/roots/test-intl/admonitions.po
Normal file
@@ -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"
|
||||
|
||||
46
tests/roots/test-intl/admonitions.txt
Normal file
46
tests/roots/test-intl/admonitions.txt
Normal file
@@ -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
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user