XML

XML localization with XPath control.

Choose with XPath which elements and attributes hold user-facing text, translate only those values, keep translations matched by a key, and write settings_de.xml with the structure untouched. Your application keeps the file format and how it loads it.

XML localization: Professional and higher

Your source XML settings.xml Lingobit Localizer New OrderNeue BestellungCustomerKundeCreateErstellen <strings></strings><item>OpenÖffnen</item><item>ExitBeenden</item> Values, translated in place;tags are protected You getsettings.xmlsettings_de.xmlsettings_fr.xmlsettings_ja.xmlA translated filefor each language;tags stay as they are Your sourceXMLsettings.xml Translate in Lingobit New OrderNeue BestellungCustomerKundeCreateErstellen <strings></strings><item>OpenÖffnen</item><item>ExitBeenden</item> You getsettings.xmlsourcesettings_de.xmlsettings_fr.xmlsettings_ja.xml
Input
.xml files and an XPath that selects the text
Output
settings_de.xml for each language, same structure
Key
An XPath key, such as ./@id, matches translations on update
Runtime
Your application loads the file for the user's language
On this page

Tutorial

Localize XML files with Lingobit, step by step.

Four steps from settings.xml to a translated file for each language.

Your source XML settings.xml Project DE FR JA LOC MyApp.loc settings.xmlXML New Order Customer: errors.xmlXML Order {0} has been saved. Report Format XML XML Your source XML settings.xml Project DE FR JA LOC MyApp.loc settings.xmlXML New Order Customer: errors.xmlXML Order {0} has been saved. Report Format XML XML
  1. Your source XML settings.xml Project DE FR JA LOC MyApp.loc settings.xmlXML New Order Customer: errors.xmlXML Order {0} has been saved. Report Format XML XML Your source XML settings.xml Project DE FR JA LOC MyApp.loc settings.xmlXML New Order Customer: errors.xmlXML Order {0} has been saved. Report Format XML XML

Translation Hints match Source Order {0} has been saved. Order %1 has been saved. Order %s has been saved. Current Bestellung {0} wurde gesichert. Bestellung %1 wurde gesichert. Bestellung %s wurde gesichert. DeepL Bestellung {0} wurde gespeichert. Bestellung %1 wurde gespeichert. Bestellung %s wurde gespeichert. 86% Google Translate Bestellung wurde gespeichert. Missing {0} Missing %1 Missing %s 71% ! Azure Translator Die Bestellung {0} wurde gespeichert. Die Bestellung %1 wurde gespeichert. Die Bestellung %s wurde gespeichert. 79% Translation memory Bestellung {0} gespeichert. Bestellung %1 gespeichert. Bestellung %s gespeichert. 68% Translation Hints match Source Order {0} has been saved. Order %1 has been saved. Order %s has been saved. Current Bestellung {0} wurde gesichert. Bestellung %1 wurde gesichert. Bestellung %s wurde gesichert. DeepL 86% Bestellung {0} wurde gespeichert. Bestellung %1 wurde gespeichert. Bestellung %s wurde gespeichert. Google Translate 71% ! Bestellung wurde gespeichert. Missing {0} Missing %1 Missing %s Azure Translator 79% Die Bestellung {0} wurde gespeichert. Die Bestellung %1 wurde gespeichert. Die Bestellung %s wurde gespeichert. Translation memory 68% Bestellung {0} gespeichert. Bestellung %1 gespeichert. Bestellung %s gespeichert.
Your files TMX XLIFF CSV Open file Ship today 100% Print preview Notify the customer. 95% Microsoft terms Cancel Folder Quantity only what matches the project Project Translation memory Ship today Noch heute versenden Notify the customer. Kunde benachrichtigen. Terminology Cancel Abbrechen Quantity Menge Your files TMX XLIFF CSV Open file Ship today100% Print preview Notify the customer.95% Microsoft terms CancelFolderQuantity only what matches the project Project Translation memory Ship today Noch heute versenden Notify the customer. Kunde benachrichtigen. Terminology Cancel→Abbrechen Quantity→Menge
ProjectDEFRJAMyApp.locsettings.xmlNew Ordererrors.xml PrepareTranslationTaskImportTranslationResults TranslatorDENew OrderNeue BestellungCustomer:Kunde:CreateErstellenSourceGermanNew OrderNeue BestellungCustomer:Kunde:Quantity:Menge:Validation on save Or their CAT toolXLIFF 1.2for the tool the translatoralready uses ProjectDEFRJAMyApp.locsettings.xmlNew Ordererrors.xml PrepareTranslation Task TranslatorDENew OrderNeue BestellungCustomer:Kunde:CreateErstellenSourceGermanNew OrderNeue BestellungCustomer:Kunde:Quantity:Menge:Validation on save Or their CAT toolXLIFF 1.2for the tool the translatoralready uses ImportResults
  1. Translation Hints match Source Order {0} has been saved. Order %1 has been saved. Order %s has been saved. Current Bestellung {0} wurde gesichert. Bestellung %1 wurde gesichert. Bestellung %s wurde gesichert. DeepL Bestellung {0} wurde gespeichert. Bestellung %1 wurde gespeichert. Bestellung %s wurde gespeichert. 86% Google Translate Bestellung wurde gespeichert. Missing {0} Missing %1 Missing %s 71% ! Azure Translator Die Bestellung {0} wurde gespeichert. Die Bestellung %1 wurde gespeichert. Die Bestellung %s wurde gespeichert. 79% Translation memory Bestellung {0} gespeichert. Bestellung %1 gespeichert. Bestellung %s gespeichert. 68% Translation Hints match Source Order {0} has been saved. Order %1 has been saved. Order %s has been saved. Current Bestellung {0} wurde gesichert. Bestellung %1 wurde gesichert. Bestellung %s wurde gesichert. DeepL 86% Bestellung {0} wurde gespeichert. Bestellung %1 wurde gespeichert. Bestellung %s wurde gespeichert. Google Translate 71% ! Bestellung wurde gespeichert. Missing {0} Missing %1 Missing %s Azure Translator 79% Die Bestellung {0} wurde gespeichert. Die Bestellung %1 wurde gespeichert. Die Bestellung %s wurde gespeichert. Translation memory 68% Bestellung {0} gespeichert. Bestellung %1 gespeichert. Bestellung %s gespeichert.
  2. Your files TMX XLIFF CSV Open file Ship today 100% Print preview Notify the customer. 95% Microsoft terms Cancel Folder Quantity only what matches the project Project Translation memory Ship today Noch heute versenden Notify the customer. Kunde benachrichtigen. Terminology Cancel Abbrechen Quantity Menge Your files TMX XLIFF CSV Open file Ship today100% Print preview Notify the customer.95% Microsoft terms CancelFolderQuantity only what matches the project Project Translation memory Ship today Noch heute versenden Notify the customer. Kunde benachrichtigen. Terminology Cancel→Abbrechen Quantity→Menge
  3. ProjectDEFRJAMyApp.locsettings.xmlNew Ordererrors.xml PrepareTranslationTaskImportTranslationResults TranslatorDENew OrderNeue BestellungCustomer:Kunde:CreateErstellenSourceGermanNew OrderNeue BestellungCustomer:Kunde:Quantity:Menge:Validation on save Or their CAT toolXLIFF 1.2for the tool the translatoralready uses ProjectDEFRJAMyApp.locsettings.xmlNew Ordererrors.xml PrepareTranslation Task TranslatorDENew OrderNeue BestellungCustomer:Kunde:CreateErstellenSourceGermanNew OrderNeue BestellungCustomer:Kunde:Quantity:Menge:Validation on save Or their CAT toolXLIFF 1.2for the tool the translatoralready uses ImportResults

Output · Validation C# Format String: inconsistent arguments settings.xml · export Fixed Resource settings.xml · export Source Export {0} pages to {1}. Export %d pages to %s. Export <b>all</b> pages. Export %1 pages to %2. German {0} Seiten nach {2} exportieren. %d Seiten nach %d exportieren. <b>Alle</i> Seiten exportieren. %1 Seiten nach %3 exportieren. {0} Seiten nach {1} exportieren. %d Seiten nach %s exportieren. <b>Alle</b> Seiten exportieren. %1 Seiten nach %2 exportieren. Output · Validation C# Format String: inconsistent arguments settings.xml · export Fixed settings.xml · export Source Export {0} pages to {1}. Export %d pages to %s. Export <b>all</b> pages. Export %1 pages to %2. German {0} Seiten nach {2} exportieren. %d Seiten nach %d exportieren. <b>Alle</i> Seiten exportieren. %1 Seiten nach %3 exportieren. {0} Seiten nach {1} exportieren. %d Seiten nach %s exportieren. <b>Alle</b> Seiten exportieren. %1 Seiten nach %2 exportieren.
  1. Output · Validation C# Format String: inconsistent arguments settings.xml · export Fixed Resource settings.xml · export Source Export {0} pages to {1}. Export %d pages to %s. Export <b>all</b> pages. Export %1 pages to %2. German {0} Seiten nach {2} exportieren. %d Seiten nach %d exportieren. <b>Alle</i> Seiten exportieren. %1 Seiten nach %3 exportieren. {0} Seiten nach {1} exportieren. %d Seiten nach %s exportieren. <b>Alle</b> Seiten exportieren. %1 Seiten nach %2 exportieren. Output · Validation C# Format String: inconsistent arguments settings.xml · export Fixed settings.xml · export Source Export {0} pages to {1}. Export %d pages to %s. Export <b>all</b> pages. Export %1 pages to %2. German {0} Seiten nach {2} exportieren. %d Seiten nach %d exportieren. <b>Alle</i> Seiten exportieren. %1 Seiten nach %3 exportieren. {0} Seiten nach {1} exportieren. %d Seiten nach %s exportieren. <b>Alle</b> Seiten exportieren. %1 Seiten nach %2 exportieren.

Project Open Öffnen Save Speichern Print Drucken Export Exportieren Removed Help Hilfe Scan for Changes New build Open Öffnen Save Speichern Print all Updated Help Hilfe Share New Project Öffnen Speichern Drucken Exportieren Hilfe Removed Scan for Changes New build Open Öffnen Save Speichern Print all Updated Help Hilfe Share New
  1. Project Open Öffnen Save Speichern Print Drucken Export Exportieren Removed Help Hilfe Scan for Changes New build Open Öffnen Save Speichern Print all Updated Help Hilfe Share New Project Öffnen Speichern Drucken Exportieren Hilfe Removed Scan for Changes New build Open Öffnen Save Speichern Print all Updated Help Hilfe Share New

An XPath picks the values, a key keeps them matched.

Without a rule, Lingobit offers every text node and every attribute of the file, IDs and numbers included. An XPath such as //message narrows it to the text your users see, and a key expression such as ./@id names each value, so translations stay matched when the file changes. Lingobit writes the same file with the values translated.

settings.xml<messages><message id="NotFound">File not found.</message><message id="Saved">Saved.</message></messages> XPath rulesValue//messageKey./@id ProjectKeySourceNotFoundFile not found.SavedSaved. Your XMLLingobit Only the values go to translators; the key keeps each translation matched when the file changes Your XML settings.xml<messages><message id="NotFound">File not found.</message><message id="Saved">Saved.</message></messages> Lingobit XPath rulesValue//messageKey./@id ProjectKeySourceNotFoundFile not found.SavedSaved. Only the values go to translators; the key keeps each translation matched when the file changes.

Lingobit does

  • Translates the elements and attributes your XPath and filters select.
  • Reuses earlier translations and the translation memory.
  • Checks placeholders, empty and too long translations, and more.
  • Writes settings_de.xml for each language, with comments and layout kept.

Your application keeps

  • The XML format and its schema.
  • Loading the file for the user's language.
  • Which values are text and which are settings.
  • The final test in the running application.

Reference

XPath patterns for common files.

Lingobit uses XPath 1.0. In a file with a default namespace, address its elements with the prefix defns, as in //defns:message; declare other prefixes under Namespaces.

XML shapes with the XPath and key expression to use
The text is inSelect nodes to translateKey expression
<message id="saved">Saved.</message>//message./@id
<folder key="docs"><title>Documents</title>//folder/title../@key
<button id="send" text="Send"/>//button/@text../@id
<caption translate="true">Setup</caption>//caption[@translate="true"]—
A file with xmlns="…"//defns:message./@id

XML settings.

Each XML file has its own settings in the project, under these names.

XML settings and what they do
SettingWhat it does
ParserNamespaces, Select nodes to translate, Key expression, and Parse comments
Node Filter, Attribute FilterAllow or deny elements and attributes by name; the attributes of selected elements are offered unless denied here
XPath MappingSends the text of selected nodes to another parser, for example HTML stored inside XML
Encoding and outputUTF-8 by default, detected from the file; the output name, by default settings_de.xml in the output folder

Do and don't.

Do

  • Set an XPath for every file, so IDs, numbers, and settings stay out of translation.
  • Set a key expression when the file has IDs: translations stay matched when elements move.
  • Deny technical attributes, such as id or style, in the Attribute Filter.
  • Name the output files the way your application loads them.

Don't

  • Translate a whole XML file without an XPath.
  • Edit settings_de.xml by hand: the next Create overwrites it.
  • Build sentences in code from translated pieces.
  • Send XML files to translators: they work in Lingobit.

Troubleshooting.

Symptoms, causes, and what to do
SymptomLikely causeWhat to do
IDs and numbers appear as stringsThe file has no XPath, so every text node and attribute is offeredSet Select nodes to translate, and deny technical attributes
The XPath selects nothingThe file has a default namespaceWrite the elements with the prefix defns, as in //defns:message
Translations are New again after an updateThere is no key expression, and the text or the place of the element changedSet a key expression such as ./@id
The application stays in EnglishThe translated file is not where the application looks, or its name differsChange the output name in the file's settings to the name your application loads

The XML sample.

Localizer installs an XML and XSL sample with its project, in German and French.

  • simple.xml, a menu of dishes: the Node Filter leaves out the price and calories elements, so only names and descriptions are translated.
  • simple.xsl, the style sheet, with its attributes left out, and index.html, the page that shows the result.

More about XML localization.

More XPath examples

Mixed XML resources

<item name="WelcomeTitle">
  <value>Welcome</value>
  <comment>Shown on the start page</comment>
</item>

Select nodes to translate: //item/value

Only <value> is translated; the comment stays out of the strings.

Key stored in a sibling element

<folder>
  <key>UserDocs</key>
  <title>User Documents</title>
</folder>

Select nodes to translate: //folder/title
Key expression:            ../key/text()

Report definitions: skip formulas

In a report definition with a default namespace, select the visible text boxes and skip calculated expressions that start with =:

//defns:Textbox[not(starts-with(normalize-space(defns:Value), "="))]/defns:Value
Translatable and protected attributes

Prefer allowing the attributes translators need over offering all of them.

Usually translated: text  tooltip  caption  title  description
Usually protected:  id  name  class  type  style  width  height  x  y  binding  resourceKey
Output patterns for localized XML files

Match the output name to the way your application or build loads the files. The default writes resources_de.xml into the project's output folder.

$(OutputDir)\$(SrcFileName)_$(CultureName)$(SrcFileExt)       out\resources_de.xml   (default)
$(OutputDir)\$(CultureName)\$(SrcFileName)$(SrcFileExt)       out\de\resources.xml
$(OutputDir)\$(SrcFileName).$(CultureName)$(SrcFileExt)       out\resources.de.xml
Which XML files fit

Good candidates have stable IDs or keys, clear text or value nodes, attributes that can be allowed by name, and a structure that stays predictable across releases. Take care with XML without stable keys, files that mix user-facing text with formulas, large mixed-content blocks, files regenerated from another source that overwrites translations, and XML where runtime logic depends on translated values.