Lingo.dev + .xml(データ)
Lingo.dev CLIはXMLファイルを翻訳する際に、ドキュメント構造、属性、名前空間、およびスキーマ準拠性を保持します。CLIはXMLスキーマとDTD準拠性を維持し、すべての名前空間宣言とプレフィックスを保持し、正確なXML階層とフォーマットを維持し、様々な文字エンコーディングを正しく処理し、出力がXML検証ツールに合格することを保証します。
クイックセットアップ
ロケールベースの命名を持つXMLファイル用に設定します:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"xml": {
"include": ["data/[locale].xml"]
}
}
}
注意:[locale]
は設定内で文字通りのプレースホルダーとして残しておく必要があります。CLI実行中に実際のロケールに置き換えられます。
XMLコンテンツを翻訳する
npx lingo.dev@latest i18n
テキストコンテンツを翻訳しながら、XML構造、属性、名前空間、およびドキュメントスキーマを保持します。
XML構造の処理
要素コンテンツ
<?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>
XML構造を維持しながら、要素内のテキストコンテンツが翻訳されます。
属性の翻訳
<item title="User Manual" description="Complete guide">
<help tooltip="Click for assistance">Getting Started</help>
</item>
技術的な属性は変更せずに、翻訳可能な属性が処理されます。
混合コンテンツの処理
<documentation>
<section title="Introduction">
Welcome to our <emphasis>comprehensive</emphasis> guide.
Visit <link href="/help">our help center</link> for more information.
</section>
</documentation>
テキストと要素が混在するコンテンツが正しく処理されます。
高度なXML機能
名前空間のサポート
<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名前空間とプレフィックスが正確に保持されます。
CDATAセクション
<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セクションは変更されません。
処理命令
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<document>
<title>Document Title</title>
</document>
処理命令とXML宣言は保持されます。
高度な設定
複数のXMLファイル
"xml": {
"include": [
"data/[locale].xml",
"config/[locale]/*.xml"
]
}
技術的要素のロック
"xml": {
"include": ["data/[locale].xml"],
"lockedKeys": ["id", "version", "timestamp", "schema"]
}