Asset features may have contexts (e.g. brand, country, … ), which are stored as children properties of the feature. When properties are translated with Translation with Memory (aka. TwM), context information is displayed in the Segments widget of the Translation Memory which stores the source and target segments with context information. After the translation, the translated properties will have the same child features as the original properties. This means that, the context information is not lost after the translation. During the translation process in TwM, the user can see contexts which are applied to the translated properties. The visual representation of the context information is done with XSLT transformation of the segment contexts XML.

Metadata Translation XML

The Metadata Translation XML contains a list of <assetFeature> nodes. Each <assetFeature> node contains a list of <source> / <target> paired nodes, one for each property translation for a specific context.

<assetFeature>
   <source language="en">value_en</source>
   <target language="de">value_de</target>
   <source language="en">value_en_for_context_1</source>
   <target language="de">value_de_for_context_1</target>
   ...
</assetFeature>

Additionally, the XML contains a list of context <segment> nodes, where each node stores information about the actual contexts (<context key=... value=...>) applied to the corresponding property translation. The corresponding <segment> nodes are matched by order.

<contexts>
   <language language="en">
       <segment>
           <context key="..." value="..."/>
            ... <!-- next context item node may go here -->
       </segment>
       ... <!-- next segment node (for property with another context) may go here -->
   </language>
   ... <!-- next language node may go here -->
</contexts>

  • Example - Metadata Translation XML:

<?xml version="1.0" encoding="UTF-8"?><meta><its:rules version="2.0" xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsx="http://www.w3.org/2008/12/its-extensions">
  <its:translateRule selector="/meta" translate="no"/>
  <its:translateRule itsx:idValue="concat(../../@id, &apos;.&apos;, ../@key, &apos;.&apos;, ../@trait, &apos;.&apos;, ../@traitProperty)" selector="//source" translate="yes"/>
  <its:translateRule selector="//target" translate="no"/>
  <its:targetPointerRule selector="//source" targetPointer="../target"/>
  <its:translateRule selector="//assetFeature/context" translate="no"/>
</its:rules>
  <assets>
    <asset id="13173">
      <assetFeatures>
        <assetFeature key="censhare:name" traitProperty="localizedName" trait="display">
          <source language="en">Superfeature</source>
          <target language="de">KlasseMerkmal</target>
          <source language="en">SUPERfeature</source>
          <target language="de">KLASSEmerkmal</target>
        </assetFeature>
      </assetFeatures>
      <contexts>
        <language language="en">
          <segment>
            <context key="censhare:product.brand" value="13174"/>
            <context key="censhare:sales-region" value="15807"/>
          </segment>
          <segment>
            <context/> <!-- no context for this segment -->
          </segment>
        </language>
        <language language="de">
          <segment>
            <context key="censhare:product.brand" value="13174"/>
            <context key="censhare:sales-region" value="15807"/>
          </segment>
          <segment>
            <context/> <!-- no context for this segment -->
          </segment>
        </language>
      </contexts>
    </asset>
  </assets>
</meta>

XSLT View Transformation

There is an XSLT resource asset (censhare:transformation.translation.ofmetadata.contexttransformation) that is executed on the Metadata Translation XML model and delivers HTML snippets for every context information that is required. The XSLT contains the order, style and localization logic for all the context labels of every segment (property). This XSLT is the same for the Segments widget, the Translation Memory widget (showing the matches) and the generic Translation Memory Table (showing all segments in the system per language). The XSLT transformation processes the list of context nodes in the Metadata Translation XML and produces XML with visual representation of the context information as HTML snippets, which will be displayed on the front-end.

  • Example of the XSLT transformation:

<meta><its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsx="http://www.w3.org/2008/12/its-extensions" version="2.0">
  <its:translateRule selector="/meta" translate="no"/>
  <its:translateRule itsx:idValue="concat(../../@id, &apos;.&apos;, ../@key, &apos;.&apos;, ../@trait, &apos;.&apos;, ../@traitProperty)" translate="yes" selector="//source"/>
  <its:translateRule selector="//target" translate="no"/>
  <its:targetPointerRule selector="//source" targetPointer="../target"/>
  <its:translateRule selector="//assetFeature/context" translate="no"/>
</its:rules>
<assets>
  <asset id="13173">
    <assetFeatures>
      <assetFeature key="censhare:name" trait="display" traitProperty="localizedName">
        <source language="en">Superfeature</source>
        <target language="de">KlasseMerkmal</target>
        <source language="en">SUPERfeature</source>
        <target language="de">KLASSEmerkmal</target>
      </assetFeature>
    </assetFeatures>
    <contexts>
      <language language="en">
        <div>
          <span class="cs-color-05" style="font-size: 1.2rem; font-weight: 400;">Brand (product): Bosch | Market: Germany</span>
        </div>
        <div>
          <span class="cs-color-05" style="font-size: 1.2rem; font-weight: 400;">No context available!</span>
        </div>
      </language>
      <language language="de">
        <div>
          <span class="cs-color-05" style="font-size: 1.2rem; font-weight: 400;">Marke (Produkt): Bosch | Market: Germany</span>
        </div>
        <div>
          <span class="cs-color-05" style="font-size: 1.2rem; font-weight: 400;">Keine Kontextinformationen verfügbar!</span>
        </div>
      </language>
    </contexts>
  </asset>
</assets></meta>

XLIFF document model

The Metadata Translation XML is then processed as source in the TwM application to generate the XLIFF document model. If property translation matches are found in the Translation Memory storage, then they are added to the XLIFF model in <mtc:matches> node. Context information is passed within the @origin attribute of the <mtc:match> node, (e.g. censhare_TM_context_string=censhare:product.brand=13174). Translation matches with relevant context (which match the source context info) are prioritized when segment pre-translation is done. Translation matches without relevant context are applied a penalty match. The penalty match value can be configured in the Segments widget of the Translation Memory.

  • Example of generated XLIFF model:

<?xml version="1.0"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="de" xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsxlf="http://www.w3.org/ns/its-xliff/" its:version="2.0">
  <file id="f1" original="/Users/vmy/workspace/develop/censhare-Server/work/temp/translation31326d1a-45d5-4e84-83a3-f94f82a9b065/101033.xml">
    <unit id="1" name=".censhare:name.display.localizedName">
      <mtc:matches xmlns:mtc="urn:oasis:names:tc:xliff:matches:2.0">
        <mtc:match ref="#1" type="other" similarity="100.0" matchSuitability="100.0" origin="censhare_TM_segment_ID=1011;censhare_TM_context_string=censhare:product.brand=13174"> <!-- Context available for this match -->
          <source>Superfeature</source>
          <target>KlasseMerkmal</target>
        </mtc:match>
      </mtc:matches>
      <segment state="initial" subState="censhare:pretranslated">
        <source><mrk id="1" type="mtc:match">Superfeature</mrk></source>
        <target>KlasseMerkmal</target>
      </segment>
    </unit>
    <unit id="2" name=".censhare:name.display.localizedName">
      <mtc:matches xmlns:mtc="urn:oasis:names:tc:xliff:matches:2.0">
        <mtc:match ref="#1" type="other" similarity="80.0" matchSuitability="80.0" origin="censhare_TM_segment_ID=1012;censhare_TM_context_string="> <!-- No context for this match -->
          <source>SUPERfeature</source>
          <target>KLASSEmerkmal</target>
        </mtc:match>
        <mtc:match ref="#1" type="other" similarity="100.0" matchSuitability="100.0" origin="censhare_TM_segment_ID=1010;censhare_TM_context_string=censhare:product.brand=13174"> <!-- Context available for this match -->
          <source>SUPERfeature</source>
          <target>KLASSEmerkmal</target>
        </mtc:match>
      </mtc:matches>
      <segment state="initial" subState="censhare:pretranslated">
        <source><mrk id="1" type="mtc:match">SUPERfeature</mrk></source>
        <target>KLASSEmerkmal</target>
      </segment>
    </unit>
  </file>
</xliff>

Persisting a context in the database table

If a segment (property) with context is translated and confirmed, the context information is stored as comma delimited string of key-value-pairs in a database field CONTEXT varchar(1024) on the Translation table. This information is a string, because it has to be stored in the XLIFF format in the @origin attribute of the <mtc:match> node. It will thus be preserved when the XLIFF is sent through Okapi pipeline.

  • Example of data stored in database column: censhare:product.brand=13174,censhare:sales-region=15545