Hi,
This is my first time posting on this forum, so please be gentle with me. Currently I'm working as a translator for Blender project, translating reference manual to Vietnamese. I have completed the UI and done some chapters on the translation set, which can be used as a database for untranslated text. I'm only interested to output to PO file. My current solution is to
1. Write an extension, and making use of 'app.connect('doctree-resolved', doctree_resolved)'.
2. Within 'doctree_resolved', I use a for loop with extract_messages(doctree) to traverse and extract all messages to be translated.
3. I use 'node.walk' with a 'visitor' (extends nodes.TreeCopyVisitor) to traverse all children nodes of the current node.
4. In the visitor, I use the 'default_visit' to traverse the children (recursively) to the end instance of nodes.Text where I use 'astext()' to extract the English text, then use a lookup routine to find appropriate 'translation' for the text.
5. Due to the fact that some texts are REQUIRED to have the original English appending to it (ending), a methodology tor leave crumbs for Vietnamese readers, who would like to reference back to English original HTML texts. These items are often from 'inline', 'title', 'rubric' etc.. so I use a flag to identify when translation texts (if exists) will include the original in it (and called this combination as translation text).
6. I use Message and Catalog to store English (msgid) and translation (msgstr) and write them out to a separate directory before merging them with existing translations by diff.
My questions:
1. How should I store translation text? Currently I'm forced to insert a variable in the 'docutils.Node' to store the translation (for testing).
2. How can I use the same 'extract_messages(doctree)' mechanism to extract English and Translation at the same time? Currently everything is tied to the overloaded 'astext()' method and that seemed to go to __repr__(self), how would I approach to solve this problem?
Best regards,
Hoang Tran
All the code is attached.