ITargetXmlFileHandler - PreTranslation.TargetXmlFileHandler
Generates the pretranslated target XML content based on the previous translation. Compares the current source document with the previous one using the proprietary algorithm; when elements were not modified, it re-uses the translation from the previous target document. The plugin is also used to purge the pretranslated context generated by it (when the translated content is submitted back to the repository) to get a valid DITA content.
Input data
The input data contains the current source document, the previously released source document, and its matching translation.
- In the previous implementation, the 'preTranslation' element id could be stored either in 'pretranslationId' or in the 'id' attribute. This logic has be simplified and the new TargetXmlFileHandler is using only the 'id' attribute.
- In the previous implementation, the 'preTranslation' element could contain nested 'preTranslation' elements. In the new TargetXmlFileHandler, the 'preTranslation' element do not create nested 'preTranslation' elements.
Pretranslation example
Imagine you have version 1 of English topic released with the following content:<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"[]>
<?ish ishref="MAKECOFFEE" version="1" lang="en"?>
<task id='MAKECOFFEE'>
<title>Making a coffee</title>
<taskbody>
<steps>
<step id='STEP1'><cmd>Boil the water and get a mug and put in a teaspoon of instant coffee.</cmd></step>
<step id='STEP2'><cmd>When the water is ready, pour in as much to fill the cup.</cmd></step>
<step id='STEP3'><cmd>Add creamer to the coffee and stir.</cmd></step>
</steps>
</taskbody>
</task> Imagine this version is translated in French, as follows:
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"[]>
<?ish ishref="MAKECOFFEE" version="1" lang="fr"?>
<task id='MAKECOFFEE'>
<title>Preparer un café</title>
<taskbody>
<steps>
<step id='STEP1'><cmd>Faire bouillir de l'eau, prendre une tasse et verser une cuillère de café instantané dans la tasse.</cmd></step>
<step id='STEP2'><cmd>Lorsque l'eau est prêt, verser en assez pour remplir la tasse.</cmd></step>
<step id='STEP3'><cmd>Ajouter de la crème dans le café et remuer.</cmd></step>
</steps>
</taskbody>
</task> Now, let's say you created the version 2 of the English topic and modified the content of the first step:
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"[]>
<?ish ishref="MAKECOFFEE" version="2" lang="en"?>
<task id='MAKECOFFEE'>
<title>Making a coffee</title>
<taskbody>
<steps>
<step id='STEP1'><cmd>Boil the water and get a mug and put in two tablespoons of sugar and a teaspoon of instant coffee.</cmd></step>
<step id='STEP2'><cmd>When the water is ready, pour in as much to fill the cup.</cmd></step>
<step id='STEP3'><cmd>Add creamer to the coffee and stir.</cmd></step>
</steps>
</taskbody>
</task> Since you only modified step 1, the title and the content of the steps 2 and 3 are left untouched. The translation of the untouched elements can therefore be reused. With the pretranslation handler, this reuse is achieved by putting the previously translated content in the same document next to the source content, wrapped in the 'preTranslation' elements.
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"[]>
<?ish ishref="MAKECOFFEE" version="2" lang="en"?>
<task id="MAKECOFFEE">
<preTranslation type="exact">
<title lang="en">Making a coffee</title>
<title lang="fr">Preparer un café</title>
</preTranslation>
<taskbody>
<steps>
<step id="STEP1"><cmd>Boil the water and get a mug and put in two tablespoons of sugar and a teaspoon of instant coffee.</cmd></step>
<preTranslation id="STEP2" type="structureChange">
<step id="STEP2" lang="en"><cmd>When the water is ready, pour in as much to fill the cup.</cmd></step>
<step id="STEP2" lang="fr"><cmd>Lorsque l'eau est prêt, verser en assez pour remplir la tasse.</cmd></step>
</preTranslation>
<preTranslation id="STEP3" type="structureChange">
<step id="STEP3" lang="en"><cmd>Add creamer to the coffee and stir.</cmd></step>
<step id="STEP3" lang="fr"><cmd>Ajouter de la crème dans le café et remuer.</cmd></step>
</preTranslation>
</steps>
</taskbody>
</task>
TargetXmlFileHandler configuration
The extension is configured in the extension configuration which is accessible from the Content Manager web client by selecting .
- IsNumericRegExp
- Provides the regular expression that is used to recognize the numeric data inside the element text.
- ComparisonElements
-
Provides the xpaths for the elements that should be used for the comparison.
- xpath - contains the single xpath that is used to retrieve elements whose content will be compared to determine whether their translation can be re-used.
- @identified - specified whether elements that are returned by the given xpath should have the same id. When the order of elements changes in the translated document, it ensures that the correct translated element is used.
TargetXmlFileHandler configuration example
This XML example shows typical configurations for the PreTranslation TargetXmlFileHandler:
<source id="PreTranslation" handler="PreTranslation">
<initialize>
<parameters>
<parameter name="ComparisonElements">
<comparisonelements>
<xpath>//*[contains(@class,' topic/section ')]</xpath>
<xpath>//*[contains(@class,' topic/example ')]</xpath>
<xpath>//*[contains(@class,' topic/shortdesc ')]</xpath>
<xpath>//*[contains(@class,' topic/table ')]</xpath>
<xpath>//*[contains(@class,' topic/row ')]</xpath>
<xpath>//*[contains(@class,' topic/ol ')]</xpath>
<xpath>//*[contains(@class,' topic/ul ')]</xpath>
<xpath>//*[contains(@class,' topic/li ')]</xpath>
<xpath>//*[contains(@class,' topic/sli ')]</xpath>
<xpath>//*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]</xpath>
<xpath>//*[contains(@class,' topic/table ')]/*[contains(@class,' topic/title ')]</xpath>
<xpath>//*[contains(@class,' topic/section ')]/*[contains(@class,' topic/title ')]</xpath>
<xpath>//*[contains(@class,' topic/navtitle ')]</xpath>
<xpath>//*[contains(@class,' topic/alt ')]</xpath>
<xpath>//*[contains(@class,' topic/indexterm ')]</xpath>
<xpath>//*[contains(@class,' topic/term ')]</xpath>
<xpath>//*[contains(@class,' topic/tm ')]</xpath>
<xpath>//*[contains(@class,' topic/fn ')]</xpath>
<xpath>//*[contains(@class,' topic/xref ')]</xpath>
</comparisonelements>
</parameter>
<parameter name="IsNumericRegExp"/>
</parameters>
</initialize>
</source>