DocsPlatform
Files and formats
Translate whole files in 13 formats while keeping their structure, what is and is not translated in each, and how to upload and download them.
On this page
Besides UI strings from code, Generic Translation translates files: locale resources, documentation, subtitles, web pages. Upload a source file, and Generic Translation parses it into text segments, translates those segments, and rebuilds a file with the same structure in each target language. Only the text is replaced: keys, markup, code, whitespace, comments and line endings are kept as they were, so a file with no translations renders byte-identical to the source.
Files go through the same pipeline as strings: segments are hashed, translations are cached per segment, and your style instructions and glossary apply. Uploading is POST /files (API), the Files page of the dashboard, or the files section of generic-translation.config.json.
Supported formats
fileFormat |
Typical extensions | Translated | Left alone |
|---|---|---|---|
json |
.json |
Every string value that contains a letter, at any depth, including in arrays | Keys, numbers, booleans, null, strings with no letters |
yaml |
.yml, .yaml |
Every string value that contains a letter | Keys, non-strings, comments, anchors |
md |
.md, .markdown |
Headings, paragraphs, list items, quotes, table cells, front matter title, description, sidebar_label, summary, excerpt |
Code blocks and inline code, URLs, link targets, HTML-only lines, rules, link definitions |
mdx |
.mdx |
Same as Markdown | Also import / export lines and JSX-only lines |
txt |
.txt |
Each paragraph (text separated by blank lines) | Blank-line separators |
html |
.html, .htm |
Text content, and the attributes alt, title, placeholder, aria-label, plus the content of description, keywords, Open Graph and Twitter title/description meta tags |
script, style, pre, noscript, comments, elements marked translate="no", all other attributes |
srt |
.srt |
The text lines of each subtitle cue | Cue numbers and timestamps |
po |
.po, .pot |
msgid and msgid_plural text, written into msgstr / msgstr[n] |
Header entry (apart from Language:), flags, comments, entries with no letters |
strings |
.strings (Apple) |
Values of "key" = "value"; pairs |
Keys, comments, empty values |
androidxml |
strings.xml |
<string>, <string-array> and <plurals> items |
Anything with translatable="false", other XML |
resx |
.resx |
<value> of plain <data> entries |
Entries with a type or mimetype, names starting with >>, values containing markup |
xliff |
.xlf, .xliff |
<source> text, written into <target> |
Units with translate="no", ids, other attributes |
csv |
.csv, .tsv |
Text cells | The header row, a leading key column, cells with no letters |
The dashboard picks the format from the extension. Through the API, you pass fileFormat explicitly. Uploads are limited to 1 MB of text per file, as UTF-8; a leading byte-order mark is preserved.
Format notes
JSON and YAML
Each string becomes one segment whose context is its key path, such as nav.items[0].label, so identical words at different places can be translated differently. A value that contains an ICU plural or select ({count, plural, one {...} other {...}}) that parses is translated as an ICU message, so its structure is validated; other values are plain text. Translated JSON is re-serialized with the indentation of the source. YAML is edited in place, so comments and layout survive.
Placeholders such as {{name}}, %s or ${name} in plain-text values are instructions to the model to keep them unchanged; they are not checked afterwards. Review translations of strings that carry many placeholders.
Markdown and MDX
Block structure is preserved: heading markers, list bullets and numbering, quote markers and table pipes stay, and only the text after them is translated. Inline markup (**bold**, links, inline code) is sent to the model with instructions to keep it, and link URLs are not translated. Front matter is read for the keys listed above; other keys are copied. In MDX, import and export statements and JSX-only lines are copied.
HTML
Inline elements (a, em, strong, span, code, img, and similar) stay inside the sentence that contains them, so a sentence with a link is translated as a unit and the link markup is kept. Block elements are separate segments. Add translate="no" to anything that must stay as it is.
PO
msgctxt and translator comments are passed to the model as context. When translations exist, msgstr is filled in (including plural forms) and the Language: header is set to the target locale. Existing msgstr values in the source are replaced for the translated language, so upload the template or source-language file.
Android, Apple, RESX
Escapes are decoded before translation and re-encoded after (\' and \n in Android, \" and \n in .strings, XML entities in RESX). The name of an Android string, the comment or key in .strings, and the comment or name in RESX are used as context.
XLIFF
Both XLIFF 1.2 (trans-unit) and 2.x (unit with segment) are read. Generic Translation writes a <target> with state="translated" and sets the target language on the file or xliff element. The <note> or the unit id is used as context.
CSV
The delimiter (comma, semicolon or tab) is detected from the first line. If the first column of the header is named key, id, identifier, name, slug or code, that column is treated as keys and not translated. Each translated cell has the context rowKey.columnHeader. Quoting is re-applied where needed.
Behavior to know
- Targets. Pick the target locales at upload, or let them default to the project’s languages. Locales that are the same language as the source are skipped.
- Status. Each (file, locale) is
pendinguntil its job finishes, thenready(orfailedwhen every segment failed). Downloading a pending locale returnsstatus: "pending"with no content. - Partial translation. A segment the model could not translate is left in the source language in the output.
- Re-uploads. Each upload creates a new file record. Segments already translated are reused from the cache, so re-uploading an edited file is cheap.
- Download names. The dashboard saves
messages.jsonfor French asmessages.fr.json. The CLI writes to the paths you configure. - Not in the editor or on the CDN. File segments are translated and cached but are not listed in the strings editor and are not part of the published CDN maps; you download the finished files.
- Not supported. Binary formats (docx, xlsx, images), and anything over 1 MB. Convert to a supported text format first.
Supported by CLI configuration
In generic-translation.config.json, each format under files has an include list of globs where [locale] stands for the source locale (to find sources) and for each target locale (to write outputs):
{
"files": {
"json": { "include": ["locales/[locale]/*.json"] },
"md": { "include": ["docs/[locale]/**/*.md"] }
}
}
See the config reference for every key.
Something wrong or unclear on this page? Open an issue.