Translation Memory with Context

TM Fill-Ups can now occur based on context for users of XLIFF, PO, XLSX & QT and FILELESS file formats.

Jacob avatar
Written by Jacob
Updated over a week ago

You can trigger TM auto fill-up tasks when both source and context matches are identified. This can easily be done by enabling the option "Translation Memory Context Matching," which can be found under your project's settings.

These TM suggestions where both context and source string are a match will be shown as a 101% TM suggestion under the suggestions tab in the editor.

Those matches where only the source string is a match and the context is different are shown as a 100% match.

📝Note: TM with Context will work with the following file formats: XLIFF, PO, XLSX, QT, and FILELESS.


Enabling TM with Context

From your Project, click Settings, then Workflow. Enable the option as indicated by the green arrow below:

📝Note: The "Translation Memory Context Matching" option is available only when the "Translation Memory Fill-up" setting is enabled


Examples of How TM with Context Works

TM Suggestions List in the Editor:

Let's say the following suggestions are available in TM:

tm-table-excel.jpg#asset:6086
  • Scenario A: User selects a resource string "Hello" without context (Context = none). In the Suggestions tab, the following suggestions will be visible (in this particular order): #2, #3, #4 (#1 will not be visible since it is the same as #4 but older). Each suggestion will be marked with a 100% match.

  • Scenario B: User selects a resource string "Hello" with the context "Greeting". In the Suggestions tab, the following suggestions will be visible (in this particular order): #4, #3, #2 (#1 will not be visible since it is the same as #4 but older). The #4 will be marked as 101%, because it is 100% text match + 100% context match

  • Scenario C: User selects a resource string "Hello" with context "greeting". In the Suggestions box, the following suggestions will be visible (in this particular order): #3, #4, #2 (#1 will not be visible since it is the same as #4 but older). Since no context matching occurs, each suggestion will be marked with a 100% match.

TM Auto-Fill

Scenario 1: If "fill-up with context" is enabled:

  • The source string has context, i.e., the context field has a value.

    • The translation text will be filled in if TM contains an entry with the same source string, context, and target language.

    • If TM contains an entry with the same source string and target language but a different context (or no context), the string will be left untranslated.

  • The source string has no context.

    • The translation text will be filled in if TM contains an entry with the same source string and target language but no context.

    • If TM contains an entry with the same source string and target language, but context is also present, the string will be left untranslated.

Scenario 2: If "fill-up with context" is not enabled:

  • The source string has context.

    • If TM contains an entry with the same source string and target language, irrespective of the context, the translation text will be filled in using the last updated translation version.

  • The source string has no context.

    • If TM contains an entry with the same source string and target language, irrespective of the context, the translation text will be filled in using the last updated translation version.

Example:

  • A JSON file with the following source string is uploaded - Source: Hello, Translation: γεια, Context: -

  • Then, a PO file with the following source string is uploaded - Source: Hello, Translation: -, Context: greeting.

  • Fill-up with context is enabled: TM won't automatically translate the "Hello" in the PO resource.

  • Fill-up with context is disabled: TM will automatically translate the "Hello" in the PO resource.


Uploading and Downloading TMX files with Context

If the localization file format you use supports context (XLIFF, PO, XLSX, QT), you can upload and download translation memory files with this information.

  • A TMX file where entries do not include context looks like this:

 <tu>
<prop type="context"></prop>
<tuv xml:lang="en">
<seg>Answer</seg>
</tuv>
<tuv xml:lang="fr">
<seg>Répondre</seg>
</tuv>
</tu>

  • A TMX file where translatable entries include context has the following syntax instead:

 <tu>
<prop type="context">Text style</prop>
<tuv xml:lang="en">
<seg>Answer</seg>
</tuv>
<tuv xml:lang="fr">
<seg>Répondre</seg>
</tuv>
</tu>

To download a TMX file with context, the checkbox 'Include string context' should be enabled as follows:

tmx_with_context_download.png#asset:6265

How Context affects source string updates

More information on how Transifex handles source string updates can be found here.

  • Updating a source string with different context - Context, for the relevant file formats, is part of the source string definition, along with key and source text. Therefore, changing the context also changes the string. This means that a new resource string is created, and any existing translations are lost.

  • Updating the context through the UI or the API is not allowed.


How Context is defined in the source files

  • XLIFF Sample:

<!--?xml version="1.0" ?--><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="en.lproj/Localizable.txt" source-language="en">
<trans-unit datatype="html" id="edc96753971323c438706da1820e74730a79d1af">
<source>Your response to this survey has already been recorded. Thank You.
</trans-unit>
</file>
</xliff>

In the case of an XLIFF file, context is defined by the attributes in the XLIFF header and the entity's ID. For example:

original:source_language:datatype: id

e.g.

context = en.lproj/Localizable.txt:English (en):plaintext:edc96753971323c438706da1820e74730a79d1af

  • PO Sample:

msgctxt "Greeting"  
msgid "Hello"
msgstr ""
  • QT Sample:

<context>   
<name>Greeting</name>
<message> <source>Hello</source></message>
</context>


💡Tip

Looking for more help? Get support from our Transifex Community Forum!

Find answers or post to get help from Transifex Support and our Community.

Did this answer your question?