Skip to main content

How to read character limits, context and reference images from XML string files

Many apps keep their UI strings in an XML file where each string comes with more than its text: a maximum length, a note for translators, and a screenshot of where it appears. With Record fields, wxrks reads those extra fields of each string and puts them next to its segment in the Editor: the limit is counted and enforced, the note shows as context (and can feed AI translation), and the screenshots show as images or as links.

💡 Who is this for? Account Admins who save XML filters for the account or an Organizational Unit (a group of clients or departments with its own settings), Project Managers who set the import settings of one XML file when creating a project, and Vendors who translate those files in the Editor.

Contents

How Record fields work

Take a string file like this one:

<strings>
  <string>
    <value segment_length="25">Your ride is on the way</value>
    <context>
      <message><![CDATA[Description: Banner shown after a rider books a trip.<br>Repo: <a href="https://github.example.com/acme/rider-app">rider-app</a>]]></message>
      <imageURL><![CDATA[<img src="https://cdn.example.com/screens/ride_banner.png"> ]]></imageURL>
    </context>
  </string>
</strings>

Each <string> is a record: one string of your app with all its fields. Only value is translated. Record fields tell wxrks where each field sits inside the record, using XPath expressions (XPath is a short path that points to an element or attribute of an XML file, for example value/@segment_length):

Field

XPath in the example

What wxrks does with it

Record

//string

Finds every string of the file.

Translatable text

value

Pairs each record with the segments of its text.

Character limit

value/@segment_length

Sets the maximum length of the translation.

Context

context/message

Shows the note next to the segment; optionally sends it to Context Sensitive translation.

Reference images

context/imageURL

Shows the screenshot next to the segment, or a link to it.

All XPaths except the record one are relative to the record: write value, not //string/value. Only the record and translatable text XPaths are required; leave the others empty for fields your file doesn't have.

The fields are read on import. The exported file is identical to the original outside the translated text: the segment_length attribute, the context and the image elements are written back unchanged.

Before you start

  • Account Admins set Record fields on an XML filter in Settings > Translation > Filter settings, for the account or for one Organizational Unit. New projects use the default filter automatically. See How to Save File Parsing Settings as a Reusable Filter.

  • Project Managers can set them for one file while creating a project, in the file's Import settings.

  • Have a sample of the XML file at hand: you need its element and attribute names to write the XPaths.

Step 1: Open the XML filter or the file's import settings

Choose where to set the fields:

  • For every project (recommended): go to Settings > Translation > Filter settings and click Add filter. In File type, choose XML, and in Filter for XML, choose Custom. Give the filter a Name.

  • For one file: while creating a project, upload the .xml file and click Import settings on it. In Filter for XML, choose Custom, or pick a filter your Account Admin already saved in Saved filters: it brings all the settings below.

Add filter dialog with a red box and badge 1 on File type set to XML, badge 2 on Filter for XML set to Custom, and badge 3 on the Apply segmentation to text switch, turned off.

Import settings of an uploaded XML file during project creation, with badge 1 on the Import settings button and badge 2 on Saved filters, where a saved XML filter is selected.

Step 2: Extract only the translatable text

The context notes and image elements must not be translated. With the Custom filter, the Tag rules decide which elements are extracted:

  1. Turn off Apply segmentation to text, so each string stays a single segment.

  2. Under Segmentation rules, find Tag rules. The Custom filter already has the rule <.*> EXCLUDE, which skips every element. Keep it.

  3. In Tag name, type the translatable element without angle brackets (value in the example) and click Add tag.

  4. Click the new <value> rule and choose INCLUDE in Rule types. Only that element is now extracted.

Tag rules list with badge 1 on the default &lt;.*&gt; EXCLUDE rule, badge 2 on the added  INCLUDE rule, and badge 3 on its Rule types field set to INCLUDE.

💡 Tip: Before saving, check the result in Extraction preview at the top of the dialog: choose an Org Unit and the Source language, drop a sample file and click Preview. Only the translatable text should be listed, one segment per string. Nothing is created.

Extraction preview of the sample file with a red box around the result: 4 segments, one per string, with no context text.

ℹ️ Note: If the parser extracts text that belongs to no record, that text is still translated, but it gets no limit, context or images.

Step 3: Point wxrks to the records and their text

  1. Turn on Record fields.

  2. In Record XPath, enter the element that holds each string, for example //string.

  3. In Translatable text XPath, enter the element with the text to translate, relative to the record, for example value.

wxrks pairs records and segments in file order and checks that their text matches, so a field never lands on the wrong string.

Record fields section with badges 1 to 5 on the Record fields switch, Record XPath //string, Translatable text XPath value, Character limit XPath value/@segment_length, and Over the limit set to Warn.

Step 4: Read the character limit

  1. In Character limit XPath, enter where the limit sits, for example value/@segment_length.

  2. In Over the limit, choose what happens when a translation is longer than the limit:

    • Warn (default): the segment can be confirmed, with a warning.

    • Block: the segment can't be confirmed, and the file can't be delivered while a translation is over its limit.

How the limit is counted:

  • Only the visible text counts. Tags and placeholders don't.

  • A record without a positive whole number (empty, zero or text) gets no limit.

  • If a string was split into several segments, the limit applies to all of them together.

💡 Tip: Choose Block when an over-limit string would break your app's layout and must never ship. Choose Warn when a reviewer may accept a slightly longer translation.

The limit works like the character limit of Excel files. See How to Configure and Use Target Char Limit in wxrks.

Step 5: Read the context

  1. In Context XPath, enter the element with the note for translators, for example context/message.

  2. Turn on Show the context in the Editor so translators see it next to the segment.

  3. Optionally, turn on Use the context in Context Sensitive (up to 400 characters). Context Sensitive (CS) is the wxrks AI step that adapts translations to their surroundings; with this option, it also reads the note. Longer notes are cut at 400 characters, and links are removed before the note is sent.

If the note is HTML, wxrks turns it into readable text: line breaks stay, tags are removed, and each link becomes a button that opens in a new tab, named after the text before it (for example Repo). Only http and https links become buttons.

Step 6: Read the reference images

  1. In Reference images XPath, enter the element that holds each screenshot, for example context/imageURL. Each element can hold HTML image tags (img with a src address) or a plain https:// address; empty elements are skipped.

  2. In Reference images, choose how translators see them:

    • Show images in the Editor (default): wxrks downloads each image and shows it next to the segment, with its link.

    • Links only: each image shows as a link that opens in a new tab. Nothing is downloaded.

  3. Make sure Show the context in the Editor is on: images and their links show only when it is.

ℹ️ Note: In Show images in the Editor, an image is downloaded only if its address is a public https:// URL to a PNG or JPEG file under 5 MB. An image that can't be downloaded (for example, a link that opens a login page) is skipped and the import goes on. The same image used by several strings is downloaded once.

💡 Tip: Choose Links only when your screenshots must stay on your own servers, or when they need a login that translators have.

Record fields with badge 1 on Context XPath context/message, badge 2 on Reference images XPath context/imageURL, badge 3 on Reference images set to Show images in the Editor, badge 4 on Show the context in the Editor and badge 5 on Use the context in Context Sensitive, both turned on.

Save the filter, or close Import settings and create the project.

Translating the file in the Editor (Vendors)

When you open a segment of a file imported with Record fields:

  • Character limit: the target header shows Max followed by the length and the limit, such as Max 35 / 25. When you type past the limit, the counter changes color and the characters beyond the limit are highlighted in the text. Shorten the translation until the highlight disappears. With Block, you can't confirm the segment while it's over the limit.

  • Context: the note shows next to the segment, with its links as buttons that open in a new tab.

  • Reference images: the screenshots show as images you can browse, or as Reference image links that open in a new tab.

Editor row over its limit: badge 1 on the target, whose header shows Max 35 / 25 and whose last characters are highlighted; badge 2 on the Repo, Key and Reference image links of the context; badge 3 on the IMAGES panel with the reference image.

If you don't see the context, check Show segment comments in the Editor's Settings tab: it shows or hides the notes that come with the segments of the file.

The QA check Target exceeds the segment's character limit also reports each translation over its limit. It is on by default; Account Admins and Project Managers can mark it Must fix so the issue can't be ignored at delivery. See How to use the wxrks QA Check Tool.

Troubleshooting

Problem

Cause and fix

The import fails with "No record of … has the text …"

No segment of the file matched a record. Check that Record XPath finds the records and that Translatable text XPath points to the element you translate, relative to the record.

The import fails with "Invalid XPath expression in the XML filter"

One of the XPaths has a syntax error. Copy the expression from the message and correct it.

Context notes appear as segments to translate

The parser extracts the context element too. Set the Tag rules as in Step 2.

Some strings have no limit

Their limit isn't a positive whole number, or their text wasn't paired with a record.

Images don't show

Show the context in the Editor is off, the mode is Links only, or the image isn't a public https:// PNG or JPEG under 5 MB.

The limit changed in the file

Update the source file of the project: the new limit replaces the old one. If a lower Block limit makes a confirmed translation too long, that segment goes back to unconfirmed.

Quick reference

Setting

Default

Notes

Record fields

Off

Required: Record XPath and Translatable text XPath.

Over the limit

Warn

Block also stops delivery.

Show the context in the Editor

Off

Also controls images and their links.

Use the context in Context Sensitive

Off

Up to 400 characters; links removed.

Reference images

Show images in the Editor

Up to 5 images per string; public https:// PNG or JPEG under 5 MB.

Context text

—

Up to 4,000 characters and 10 links per string.

Related articles

Did this answer your question?