Skip to content

Commit 28cdeaf

Browse files
Daniel Jonesclaude
andcommitted
docs(supported-languages): migrate more prose lists + expand component docs
Replaces hand-typed language lists with `<SupportedLanguages>` in: - api-reference/improve-text.mdx — `target_lang` ParamField (the earlier commit only migrated `writing_style` and `tone`; the ParamField's own list still hand-typed). - api-reference/style-rules.mdx — POST `language` ParamField. - api-reference/translate.mdx — `formality` and `custom_instructions` ParamFields. - api-reference/document.mdx — `formality` ParamField. - docs/best-practices/custom-instructions.mdx — technical-constraints supported-target-languages bullet. Adds the import to each file that did not already have one. In every case the migrated component output is more accurate than the prose list it replaces (e.g. `formality` for text translation now reflects all 16 langs the API returns rather than the 11-entry manual list, with the regional variants). Also: - Adds a JSDoc-style block above `SupportedLanguages` that documents every prop, when each is required, valid values per resource, and three usage examples. - Promotes the `translation_memory.json` exception in `data/v3-languages/README.md` to a general "Stand-in files for APIs not yet in /v3/languages" pattern with a three-step recipe. The snippet generator already walks `data/v3-languages/*.json`, so any new manual file picked up by the recipe is wired in automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 677244f commit 28cdeaf

7 files changed

Lines changed: 121 additions & 19 deletions

File tree

api-reference/document.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebarTitle: "Overview"
44
public: true
55
---
66

7+
import { SupportedLanguages } from "/snippets/supported-languages.jsx"
8+
79
The document translation API allows you to translate whole documents and supports the following file types and extensions:
810

911
* `docx` / `doc` - Microsoft Word Document
@@ -146,7 +148,11 @@ These examples are for demonstration purposes only. In production code, the auth
146148
The name of the uploaded file. Can be used as an alternative to including the file name in the file part's content disposition.
147149
</ParamField>
148150
<ParamField body="formality" type="string">
149-
Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages `DE` (German), `FR` (French), `IT` (Italian), `ES` (Spanish), `NL` (Dutch), `PL` (Polish), `PT-BR` and `PT-PT` (Portuguese), `JA` (Japanese), and `RU` (Russian). Learn more about the plain/polite feature for Japanese <a href="https://support.deepl.com/hc/en-us/articles/6306700061852-About-the-plain-polite-feature-in-Japanese">here</a>. Setting this parameter with a target language that does not support formality will fail, unless one of the `prefer_...` options are used. To check formality support dynamically, call <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=translate_document</code></a> and look for the <code>formality</code> feature key on the target language. Possible options are:
151+
Sets whether the translated text should lean towards formal or informal language. Currently supported for the following target languages:
152+
153+
<SupportedLanguages mode="bullets" resource="translate_document" feature="formality" direction="target" />
154+
155+
Learn more about the plain/polite feature for Japanese <a href="https://support.deepl.com/hc/en-us/articles/6306700061852-About-the-plain-polite-feature-in-Japanese">here</a>. Setting this parameter with a target language that does not support formality will fail, unless one of the `prefer_...` options are used. To check formality support dynamically, call <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=translate_document</code></a> and look for the <code>formality</code> feature key on the target language. Possible options are:
150156
<ul>
151157
<li>`default` (default)</li>
152158
<li>`more` - for a more formal language</li>

api-reference/improve-text.mdx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,7 @@ curl -X POST 'https://api.deepl.com/v2/write/rephrase' \
6767
<ParamField body="target_lang" type="string">
6868
The language of the improved text. Currently, the following languages are supported:
6969

70-
* `de` (German)
71-
* `en-GB` (British English)
72-
* `en-US` (American English)
73-
* `es` (Spanish)
74-
* `fr` (French)
75-
* `it` (Italian)
76-
* `ja` (Japanese)
77-
* `ko` (Korean)
78-
* `pt-BR` (Brazilian Portuguese)
79-
* `pt-PT` (Portuguese)
80-
* `zh`/`zh-Hans` (simplified Chinese)
70+
<SupportedLanguages mode="bullets" resource="write" direction="target" />
8171

8272
You can also retrieve supported languages programmatically via <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=write</code></a>.
8373

api-reference/style-rules.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebarTitle: "Overview"
44
description: "Manage a shared list of rules for style, formatting, and more"
55
---
66

7+
import { SupportedLanguages } from "/snippets/supported-languages.jsx"
8+
79
<Info>
810
The Style Rules API is currently available only to Pro API subscribers.
911
</Info>
@@ -161,7 +163,9 @@ Create a new style rule list with configured rules and optional custom instructi
161163
The name of the style rule list. Maximum length: 1024 characters.
162164
</ParamField>
163165
<ParamField body="language" type="string" required>
164-
The target language for the style rules. Supported values: `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh`.
166+
The target language for the style rules. Supported values:
167+
168+
<SupportedLanguages resource="style_rules" />
165169
</ParamField>
166170
<ParamField body="configured_rules" type="object">
167171
An object containing predefined rules to enable for the style rule list. Rules are organized by category (e.g., `dates_and_times`, `punctuation`). Each category can contain multiple rule options.

api-reference/translate.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: "API reference for translating text with the DeepL API."
55
public: true
66
---
77

8+
import { SupportedLanguages } from "/snippets/supported-languages.jsx"
9+
810
The text-translation API currently consists of a single endpoint, `translate`, which is described below.
911

1012
For highest translation quality, we recommend using our next-gen models. For details, please see [here](/api-reference/translate#about-the-model_type-parameter).
@@ -267,7 +269,11 @@ error.
267269
</Info>
268270
</ParamField>
269271
<ParamField body="formality" type="string">
270-
Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages <code>DE</code> (German), <code>FR</code> (French), <code>IT</code> (Italian), <code>ES</code> (Spanish), <code>ES-419</code> (Latin American Spanish), <code>NL</code> (Dutch), <code>PL</code> (Polish), <code>PT-BR</code> and <code>PT-PT</code> (Portuguese), <code>JA</code> (Japanese), and <code>RU</code> (Russian). Learn more about the <a href="https://support.deepl.com/hc/en-us/articles/6306700061852-About-formality-plain-and-polite-tones-in-Japanese">plain/polite feature for Japanese ↗️</a>. To check formality support dynamically, call <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=translate_text</code></a> and look for the <code>formality</code> feature key on the target language.
272+
Sets whether the translated text should lean towards formal or informal language. Currently supported for the following target languages:
273+
274+
<SupportedLanguages mode="bullets" resource="translate_text" feature="formality" direction="target" />
275+
276+
Learn more about the <a href="https://support.deepl.com/hc/en-us/articles/6306700061852-About-formality-plain-and-polite-tones-in-Japanese">plain/polite feature for Japanese ↗️</a>. To check formality support dynamically, call <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=translate_text</code></a> and look for the <code>formality</code> feature key on the target language.
271277

272278
<p>Setting this parameter with a target language that does not support formality will fail, unless one of the <code>prefer_...</code> options are used. Possible options are:</p>
273279
<ul>
@@ -296,9 +302,11 @@ error.
296302
<ParamField body="custom_instructions" type="array[string]">
297303
Specify a list of instructions to customize the translation behavior. Up to 10 custom instructions can be specified, each with a maximum of 300 characters.
298304

299-
<Info>
300-
The target language must be `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh` or any variants of these languages.
305+
The target language must be one of:
306+
307+
<SupportedLanguages resource="translate_text" feature="style_rules" direction="target" />
301308

309+
<Info>
302310
Any request with the `custom_instructions` parameter enabled will default to use the `quality_optimized` model type. Requests combining `custom_instructions` and `model_type: latency_optimized` will be rejected. You can find best practices on how to write custom instructions [here](/docs/best-practices/custom-instructions).
303311
</Info>
304312
To check language support dynamically, call <a href="/api-reference/languages/retrieve-supported-languages-by-resource"><code>GET /v3/languages?resource=translate_text</code></a> and check for the <code>style_rules</code> feature key on the target language.

data/v3-languages/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ Each per-resource file requests `include=beta&include=external` so the vended da
1616

1717
These files are refreshed hourly by the [`refresh-v3-languages`](../../.github/workflows/refresh-v3-languages.yml) GitHub Action, which runs [`scripts/fetch_v3_languages.py`](../../scripts/fetch_v3_languages.py) and opens a pull request whenever the API responses change. See that script's module docstring or `--help` for flags and behaviour (auth, alternate endpoints, manual local refresh).
1818

19-
## `translation_memory.json`
19+
## Stand-in files for APIs not yet in `/v3/languages`
2020

21-
Translation Memory is not yet exposed by `/v3/languages`, so `translation_memory.json` is currently maintained by hand in the shape of a `/v3/languages` response. The fetcher skips it; once the API exposes Translation Memory as a resource, the next refresh will overwrite the manual file with the real response and no other code has to change.
21+
When a DeepL API needs a supported-languages list in the docs but is not yet exposed as a `/v3/languages` resource, you can hand-write a stand-in file here and the rest of the tooling will treat it like a real response. This is how `translation_memory.json` works today, and the same pattern applies to any future API that has not landed in `/v3/languages` yet.
22+
23+
To add one:
24+
25+
1. Create `data/v3-languages/<api>.json`, where `<api>` is the resource name you expect the API to expose (snake_case, no spaces).
26+
2. Fill it with an array shaped exactly like a real `/v3/languages?resource=<api>` response — each entry needs `lang`, `name`, `status`, `usable_as_source`, `usable_as_target`, and a `features` object (use `{}` if there are no per-language features yet).
27+
3. Commit the file. The snippet generator picks it up on the next run (it walks `data/v3-languages/*.json` and inlines every file it finds), so `<SupportedLanguages resource="<api>" ... />` immediately works in MDX.
28+
29+
You do not need to touch `scripts/fetch_v3_languages.py` or the workflow. The fetcher only writes files it actually fetched, so the manual file is left alone every run.
30+
31+
Once the API does land in `/v3/languages/resources`, the very next refresh will overwrite the stand-in file with the real response and the docs stay in sync — no code change required. When that happens, double-check the fields match (the manual schema was a best guess) and delete this paragraph from the README if there are no remaining stand-ins.
32+
33+
### Current stand-ins
34+
35+
- `translation_memory.json` — Translation Memory languages. Will be replaced automatically once Translation Memory ships as a `/v3/languages` resource.

docs/best-practices/custom-instructions.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: "Learn how to create effective custom instructions to customize you
44
public: true
55
---
66

7+
import { SupportedLanguages } from "/snippets/supported-languages.jsx"
8+
79
The `custom_instructions` parameter allows you to provide natural language instructions that customize how the DeepL API translates text. This guide provides best practices for creating effective custom instructions that produce consistent, high-quality results.
810

911
## What are custom instructions?
@@ -84,9 +86,12 @@ When using custom instructions, keep these constraints in mind:
8486

8587
- **Maximum instructions**: Up to 10 custom instructions per request
8688
- **Character limit**: Each instruction can contain a maximum of 300 characters
87-
- **Supported target languages**: `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh`, or any variants of these languages
8889
- **Model requirement**: Requests with `custom_instructions` automatically use the `quality_optimized` model type
8990

91+
**Supported target languages:**
92+
93+
<SupportedLanguages resource="translate_text" feature="style_rules" direction="target" />
94+
9095
<Warning>
9196
Combining `custom_instructions` with `model_type: latency_optimized` will result in an error. Custom instructions require the quality-optimized model.
9297
</Warning>

snippets/supported-languages.jsx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,78 @@
1+
/**
2+
* Render a list (or the full interactive table) of DeepL-supported
3+
* languages drawn from the vended /v3/languages responses inlined
4+
* below. The component is sandboxed by Mintlify, so the data has to
5+
* ship inside this file; see `scripts/fetch_v3_languages.py` for how
6+
* the `RESOURCES` block is refreshed.
7+
*
8+
* Drop the component wherever you would have hand-typed a language
9+
* list. It must appear at the block level (its own line); MDX does
10+
* not honour component references mid-paragraph.
11+
*
12+
* Props
13+
* -----
14+
* mode: 'inline' (default) | 'bullets' | 'table'
15+
* - 'inline' - comma-separated `<code>{lang}</code>` list. Use for
16+
* prose like "supported target languages: `de`, `en`, ..."
17+
* - 'bullets' - vertical bulleted list of `<code>{lang}</code> ({name})`.
18+
* Use for API parameter docs where each language has a
19+
* sub-bullet.
20+
* - 'table' - the full interactive sortable / filterable table.
21+
* The `resource`, `feature`, `direction`, and
22+
* `includeBeta` props are ignored in this mode; the
23+
* table merges signals across every relevant resource.
24+
*
25+
* resource: string (required for 'inline' and 'bullets')
26+
* Name of the /v3/languages resource to read from. Must match a
27+
* key in the inlined `RESOURCES` object — i.e. one of
28+
* `translate_text`, `translate_document`, `voice`, `write`,
29+
* `glossary`, `style_rules`, or `translation_memory`. When omitted,
30+
* the component falls back to `translate_text` so the call still
31+
* renders, but you almost always want to set this explicitly so the
32+
* list matches the feature you are documenting.
33+
*
34+
* feature: string (optional)
35+
* API feature key to filter by, exactly as it appears in the
36+
* `features` object of a /v3/languages response (snake_case). Only
37+
* languages that list this feature in their `features` object are
38+
* included. Examples by resource:
39+
* - translate_text / translate_document: 'auto_detection',
40+
* 'formality', 'glossary', 'style_rules', 'tag_handling'
41+
* - write: 'auto_detection', 'tone', 'writing_style'
42+
* - voice: 'auto_detection', 'formality', 'glossary',
43+
* 'transcription', 'translated_speech'
44+
* Omit the prop to include every language in the chosen resource.
45+
*
46+
* direction: 'source' | 'target' (optional)
47+
* - 'source' keeps languages with `usable_as_source: true`.
48+
* - 'target' keeps languages with `usable_as_target: true`.
49+
* Omit to include both. Use this whenever the feature is
50+
* directional (e.g. style_rules / writing_style / tone are
51+
* target-only; auto_detection is source-only).
52+
*
53+
* includeBeta: boolean (default false)
54+
* When true, also include languages whose `status` is not
55+
* 'stable' (e.g. 'beta' or 'early_access'). The hourly refresh
56+
* already vends languages and features at every status, so this
57+
* prop just chooses what to show.
58+
*
59+
* Examples
60+
* --------
61+
* <SupportedLanguages mode="table" />
62+
*
63+
* <SupportedLanguages
64+
* resource="translate_text"
65+
* feature="style_rules"
66+
* direction="target"
67+
* />
68+
*
69+
* <SupportedLanguages
70+
* mode="bullets"
71+
* resource="write"
72+
* feature="writing_style"
73+
* direction="target"
74+
* />
75+
*/
176
export const SupportedLanguages = ({
277
mode = 'inline',
378
resource,

0 commit comments

Comments
 (0)