Skip to content

同居翻訳済みSVG (doc-system)

翻訳されたSVGイラストが、各ロケールのコンテンツディレクトリにある翻訳されたドキュメント(併置されたスクリーンショットと同じ場所)と一緒に表示されるドキュメントシステムサイトで使用します。Docusaurusプリセットが主な例です。

設定

json
"features": {
  "translateSVG": true
},
"svg": {
  "sourcePath": [
    "documentation/static/assets/diagram.svg"
  ],
  "outputDir": "documentation/i18n",
  "style": "nested",
  "pathTemplate": "{outputDir}/{locale}/docusaurus-plugin-content-docs/current/assets/{basename}",
  "forceLowercase": true
}

translate-svg は、併置されたスクリーンショットがPNGに使用するのと同じ current/assets/ ディレクトリに、ロケールごとに1つのSVGを書き込みます。

documentation/i18n/de/docusaurus-plugin-content-docs/current/assets/diagram.svg
documentation/i18n/fr/docusaurus-plugin-content-docs/current/assets/diagram.svg

ソースMarkdown

すべてのロケールのドキュメントは同じ相対パスを使用します。

markdown
![Diagram](../assets/diagram.svg)

英語ロケールでは、シンボリックリンクdocs/assets → ../static/assetsがこれを解決します。翻訳済みロケールでは、直接current/assets/に解決されます。

英語のソースドキュメントと翻訳済み出力ドキュメントはパスが同一のため、regexAdjustmentsルールは必要ありません。

SVGソースの場所

推奨:ソースSVGをen-GB用PNGと同じ場所であるdocumentation/static/assets/内に保存してください。これにより、すべてのドキュメントアセットが1か所にまとまり、同じdocs/assetsシンボリックリンクで両方をカバーできます。svg.sourcePathのエントリは、その後documentation/static/assets/name.svgを指すようにします。

pathTemplate プレースホルダー

プレースホルダー
{outputDir}svg.outputDirの絶対パス(解決後)
{locale}ターゲットロケールコード
{LOCALE}ロケールコード(大文字)
{relPath}sourcePathルートからソースSVGへの相対パス
{stem}拡張子なしのファイル名
{basename}拡張子付きのファイル名
{extension}ドットを含む拡張子
{relativeToSourceRoot}最も近いsourcePathルートからの相対パス

SVG設定テーブルの完全なリファレンス。

実装例

duplistatusai-i18n-tools.config.json 内の pathTemplate を含むネストされた svg ブロック。documentation/static/assets/ 内のソースSVG(例: duplistatus_toolbar.svg)。translate-svg はロケールごとのファイルをコロケーションされたPNGの隣の documentation/i18n/<locale>/…/current/assets/ に書き込みます。ドキュメントは ../assets/ パス経由でそれらを埋め込み(例: overview.md)、regexAdjustments ブリッジは不要です。


MITライセンスの下で公開されています。