#108 Need title node source/line information for sphinx translation

sphinx (1)

Sphinx's i18n feature needs "node.source" and "node.line" value for translation process.

(see also: https://sourceforge.net/p/docutils/patches/100/)

Sphinx extract translation target message from parsed doctree. Sphinx uses nodes that are instance of nodes.TextElement and have source information as translation target messages:


Docutils parses admonition directive as nodes.admonition. nodes.admonition has child node as nodes.title but it doesn't have source/line information.

Could you set source information to term node? I attach a patch to do it.

1 Attachments


  • Günter Milde

    Günter Milde - 2013-07-03

    I applied a simplified patch:

    • admonition_node.document = self.state_machine.document

    I don't think adding the document to an admonition node is the right thing.
    (Provide arguments if/why this is really required.)

    Replaced the newline-escaping backslash with parentheses.

    • Shimizukawa Takayuki

      The goal is to set the line and source to the nodes.title instance. admonition_node.__add__(child) need admonition.document to set source and line to child.

      If I just order to achieve the object, I set source and line attribute to nodes.title instance directly (new docutils-admonition-title2.patch did).

      Last edit: Shimizukawa Takayuki 2013-07-03
      • Günter Milde

        Günter Milde - 2013-07-03

        The second patch is better.
        Alternatively, you can store .source and .line in the admonition node
        and let the translator look up node.parent.source/line.

  • Günter Milde

    Günter Milde - 2013-07-03
    • status: open --> pending-remind
  • Günter Milde

    Günter Milde - 2013-07-12

    Applied patch version 2. Please check out and test.

    • Shimizukawa Takayuki

      It's OK!
      I tested with docutils-0.11. Sorry for late reply.

  • Günter Milde

    Günter Milde - 2015-02-19
    • status: pending-remind --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks