Lingo.dev + .xml (Data)
Lingo.dev CLI translates XML files while preserving document structure, attributes, namespaces, and schema compliance. The CLI maintains XML schema and DTD compliance, preserves all namespace declarations and prefixes, keeps exact XML hierarchy and formatting, handles various character encodings correctly, and ensures output passes XML validation tools.
Quick Setup
Configure for XML files with locale-based naming:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"xml": {
"include": ["data/[locale].xml"]
}
}
}
Reminder: [locale]
is a placeholder that should remain in the config literally, as it's replaced with the actual locale during CLI run.
Translate XML Content
npx lingo.dev@latest i18n
Preserves XML structure, attributes, namespaces, and document schemas while translating text content.
XML Structure Handling
Element Content
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<product id="123">
<name>Premium Widget</name>
<description>High-quality widget for professionals</description>
<category>Tools</category>
</product>
</catalog>
Text content within elements gets translated while XML structure remains intact.
Attribute Translation
<item title="User Manual" description="Complete guide">
<help tooltip="Click for assistance">Getting Started</help>
</item>
Translatable attributes are processed while technical attributes remain unchanged.
Mixed Content Handling
<documentation>
<section title="Introduction">
Welcome to our <emphasis>comprehensive</emphasis> guide.
Visit <link href="/help">our help center</link> for more information.
</section>
</documentation>
Mixed text and element content is handled correctly.
Advanced XML Features
Namespace Support
<root xmlns:ui="http://example.com/ui"
xmlns:data="http://example.com/data">
<ui:label>Welcome Message</ui:label>
<data:content ui:title="Page Title">
Content goes here
</data:content>
</root>
XML namespaces and prefixes are preserved exactly.
CDATA Sections
<content>
<![CDATA[
This is raw content that won't be translated,
including <tags> and special characters.
]]>
</content>
<message>This text will be translated</message>
CDATA sections remain untouched while regular text content gets processed.
Processing Instructions
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<document>
<title>Document Title</title>
</document>
Processing instructions and XML declarations are preserved.
Advanced Configuration
Multiple XML Files
"xml": {
"include": [
"data/[locale].xml",
"config/[locale]/*.xml"
]
}
Lock Technical Elements
"xml": {
"include": ["data/[locale].xml"],
"lockedKeys": ["id", "version", "timestamp", "schema"]
}