Add Docbook XML mode in tools/generatedocbook

tools/generatepot uses Docbook XML mode.
It replaces elements of several types with placeholder.

  eg: <command>ps aux</command>  ->  <placeholder-1>
      [aaa.xml]
        run <command>ps aux</command>.
      [aaa.pot]
        msgid "run <placeholder-1>."
        msgstr ""

Then, translatores translate strings with placeholder.

  eg: [ja.po]
        msgid "run <placeholder-1>."
        msgstr "<placeholder-1> wo jikkou."

So, tools/generatedocbook need to merge the tranlation strings,
considering Docbook format.

If not be considered, the strings containing a placeholder
element remains untranslated because msgid does not match.

  eg: [aaa.xml]
        run <command>ps aux</command>.
      [ja.po]
        msgid "run <placeholder-1>."    <- not match
        msgstr "<placeholder-1> wo jikkou."

Change-Id: Ieb32ed8bfb0b6880040e47e3700b812f81598d8a
This commit is contained in:
KATO Tomoyuki 2013-07-09 13:45:06 +09:00
parent 84046ecb96
commit b47d0fb633
1 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,16 @@ from optparse import OptionParser
import codecs
from xml2po import Main
from xml2po.modes.docbook import docbookXmlMode
class myDocbookXmlMode(docbookXmlMode):
def __init__(self):
self.lists = ['itemizedlist', 'orderedlist', 'variablelist',
'segmentedlist', 'simplelist', 'calloutlist', 'varlistentry', 'userinput',
'computeroutput','prompt','command','screen']
self.objects = [ 'figure', 'textobject', 'imageobject', 'mediaobject',
'screenshot','literallayout', 'programlisting' ]
default_mode = 'docbook'
operation = 'merge'
options = {
@ -68,6 +78,7 @@ def mergeSingleDocument(folder, language):
outputpath = os.path.join(os.path.curdir, "generated", language, relpath)
try:
xml2po_main = Main(default_mode, operation, outputpath, options)
xml2po_main.current_mode = myDocbookXmlMode()
xml2po_main.merge(mofile_tmppath, aXML)
outputfiles.append(outputpath)
except IOError: