Skip to content

Commit 45b5b95

Browse files
Daniel Jonesclaude
andcommitted
feat(snippets): single SupportedLanguages component over vended JSON
Replaces the standalone LanguageTable snippet with one `<SupportedLanguages>` component. Doc authors drop it anywhere they need to list languages and pass props that mirror the `GET /v3/languages` contract: - `mode`: `inline` (default, comma-separated codes) | `bullets` | `table` (the existing interactive sortable/filterable table). - `resource`: matches a /v3/languages resource (`translate_text`, `translate_document`, `voice`, `write`, `glossary`, `style_rules`, `translation_memory`). - `feature`: API feature key (`style_rules`, `writing_style`, `tone`, `auto_detection`, `glossary`, `tag_handling`, ...). - `direction`: `source` | `target`. - `includeBeta`: bool. The snippet inlines a `RESOURCES` object holding the verbatim /v3/languages responses, refreshed by the hourly workflow via `scripts/generate_language_table.py`. Mintlify's snippet sandbox does not honour ES module imports, so the data has to ship inside the snippet file itself. Operators not supported by the sandbox (`in`, notably) are avoided. Adds `data/v3-languages/translation_memory.json` shaped like a /v3/languages response so the real API response can drop in unchanged once Translation Memory ships as a resource. Wires the regen step into `.github/workflows/refresh-v3-languages.yml` so each hourly refresh produces a single PR containing both the updated JSON and the regenerated snippet. Migrates the two `docs`/`api-reference` places that hand-typed feature language lists to use `<SupportedLanguages>` instead. The quality-estimation page keeps its manual list for now because QE is not exposed as a /v3/languages resource yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 366cc68 commit 45b5b95

9 files changed

Lines changed: 1142 additions & 305 deletions

File tree

‎.github/workflows/refresh-v3-languages.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
DEEPL_AUTH_KEY: ${{ secrets.DEEPL_API_KEY }}
2929
run: python3 scripts/fetch_v3_languages.py
3030

31+
- name: Regenerate snippets/language-table.jsx from vended data
32+
run: python3 scripts/generate_language_table.py
33+
3134
- name: Open or update refresh PR
3235
uses: peter-evans/create-pull-request@v6
3336
with:
@@ -37,14 +40,17 @@ jobs:
3740
title: "chore(v3-languages): refresh vended responses"
3841
body: |
3942
Automated refresh of `data/v3-languages/` from `https://api.deepl.com/v3/languages`,
40-
opened by the `refresh-v3-languages` workflow.
43+
with `snippets/language-table.jsx` regenerated from the new responses. Opened by
44+
the `refresh-v3-languages` workflow.
4145
4246
This PR is rewritten in place on each run: if the vended responses change again
4347
before merge, the branch is force-pushed with a new single squashed commit so the
4448
diff against `main` always reflects the latest API state. If a run finds the
4549
responses identical to what is already on the branch, the branch is left untouched.
4650
If a run finds the responses match `main` (e.g. the PR was merged), this PR is
4751
closed and the branch deleted automatically.
48-
add-paths: data/v3-languages/**
52+
add-paths: |
53+
data/v3-languages/**
54+
snippets/language-table.jsx
4955
delete-branch: true
5056
labels: automated, v3-languages

‎api-reference/improve-text.mdx‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Improve text"
33
public: true
44
sidebarTitle: "Overview"
55
---
6+
7+
import { SupportedLanguages } from "/snippets/language-table.jsx"
8+
69
<Info>
710
**Introducing DeepL API for Write**
811

@@ -100,15 +103,7 @@ curl -X POST 'https://api.deepl.com/v2/write/rephrase' \
100103
</Expandable>
101104
Currently supported for the following target languages:
102105

103-
* `de` (German)
104-
* `en-GB` (British English)
105-
* `en-US` (American English)
106-
* `es` (Spanish)
107-
* `fr` (French)
108-
* `it` (Italian)
109-
* `pt-BR` (Brazilian Portuguese)
110-
* `pt-PT` (Portuguese)
111-
106+
<SupportedLanguages mode="bullets" resource="write" feature="writing_style" direction="target" />
112107

113108
Styles prefixed with `prefer_` will fall back to the `default` style when used with a language that does not support styles (this is recommended for cases where no `target_lang` is set), the non-prefixed writing styles (except `default`) will return a HTTP 400 error in that case.
114109

@@ -135,14 +130,7 @@ curl -X POST 'https://api.deepl.com/v2/write/rephrase' \
135130

136131
Currently supported for the following target languages:
137132

138-
* `de` (German)
139-
* `en-GB` (British English)
140-
* `en-US` (American English)
141-
* `es` (Spanish)
142-
* `fr` (French)
143-
* `it` (Italian)
144-
* `pt-BR` (Brazilian Portuguese)
145-
* `pt-PT` (Portuguese)
133+
<SupportedLanguages mode="bullets" resource="write" feature="tone" direction="target" />
146134

147135
Tones prefixed with `prefer_` will fall back to the `default` tone when used with a language that does not support tones (this is recommended for cases where no `target_lang` is set), the non-prefixed tones (except `default`) will return a HTTP 400 error in that case.
148136

‎data/v3-languages/resources.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
"needs_source_support": true,
6969
"needs_target_support": true
7070
},
71+
{
72+
"name": "spoken_terms",
73+
"needs_source_support": true
74+
},
7175
{
7276
"name": "transcription",
7377
"needs_source_support": true

0 commit comments

Comments
 (0)