Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

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

None
pending-remind
nobody
sphinx (1)
5
2013-07-12
2013-07-03
No

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:

https://bitbucket.org/birkenfeld/sphinx/src/776565367102/sphinx/util/nodes.py#cl-63

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

Discussion

  • 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.

     
    • 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.

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