Localization
The yfm translate command translates project documentation from one language into others. Text is extracted from the markup, translated using the selected method, and assembled back into files - the project structure, markup, and code are preserved.
In a multilingual project, each language version lives in its own language folder (ru/, en/, and so on) with its own toc.yaml and content files.
Translation methods
Machine translation
Translation via Yandex Translate - the default method, used when the --provider option is omitted. The fastest option, but the result usually needs proofreading. For details, see Machine translation.
AI translation
Translation with large language models: the yandexgpt, openai, openrouter, and anthropic providers. Supports glossaries, prompts, a translation cache, and quality evaluation by a second model. For details, see AI translation.
XLIFF exchange with CAT tools
If translation is done by people in a Computer Assisted Translation (CAT) tool, the extract subcommand exports the project text into *.xliff files, and compose assembles the translated files back into documentation. For details, see XLIFF exchange with CAT tools.
How translation works
Each document is split into segments - sentences, headings, table cells. YFM markup, HTML tags, code, and Liquid constructs are not sent for translation: they stay in the document "skeleton", and after translation the segments are put back in place. Repeated segments are translated once.
Files of each language live in their own language folder: sources, for example, in ru/, and the translation result in the target language folder, for example en/. You don't need to specify the language folder in paths - it is added automatically based on the --source and --target values.
What is translated
By default, translation covers files matching {lang}/**/*.@(md|yaml|json):
*.md- YFM markup text;*.yamland*.json- only the fields described in a translation schema.
Translation schemas for YAML and JSON
A schema defines which fields of a structured file contain translatable text. Built-in schemas exist for:
toc.yamltables of contents;- leading pages
index.yaml; - variable presets
presets.yaml; - Page constructor pages.
Custom schemas can be plugged in with the --schema option of the extract subcommand.
Common parameters
These parameters work the same in all translation methods. Method-specific parameters are described in the articles on machine translation, AI translation, and XLIFF exchange.
|
Parameter |
Description |
|
|
Source document language in ISO 639-1 format: |
|
|
Target language: |
|
|
Path to the project root or to a specific file in the project. Defaults to the directory the command is run from |
|
|
Path to the project root where the translation should be saved. Defaults to |
|
|
Paths to files to translate (relative to |
|
|
Rule for selecting files: a path, a glob pattern, or a list file. Can be repeated. The rules you pass replace the default rule; to restore it, add a separate |
|
|
Rule for excluding files: a path or a glob pattern. Applied after |
|
|
Path to the configuration file. Defaults to |
Provider translation parameters
These work when translating via Yandex Translate and AI providers, but not in the extract and compose subcommands.
|
Parameter |
Description |
|
|
Translation system: |
|
|
Adds files changed in the git or arc working copy to the translation. The |
|
|
Build variables in JSON format. The |
|
|
Do not translate, only estimate the amount of text and the number of provider requests |
|
|
Copy non-translatable files (images and other assets) from the source language folder to the target language folders, so the translated version builds on its own |
|
|
Timeout for a single translation API request, in milliseconds. Defaults to |
Fixed file list
If you need to limit translation to a known set of files, a list file - for example, translate.list - is more convenient than glob patterns. Pass it to the --files or --include parameter:
yfm translate --files ./translate.list --source ru --target en
# The file supports comments and empty lines
# Paths are resolved relative to the translate.list file itself
./some/path/to/translated/file-1.md
./some/path/to/translated/file-2.md
# Paths must not point above translate.list
# Example of an invalid path:
../some/path/to/translated/file.md
Excluding content from translation
Parts of the content can be excluded from translation right in the markup.
-
translate=no- for code blocks:```sql translate=no SELECT * FROM posts WHERE id=123 LIMIT 1 ``` -
`` - for inline fragments (works in md and yaml files):
Date format: ISO 8601 with an offset from UTC. -
:::no-translate- for content blocks:This entire block will not be sent for translation.