feat(snippets): regenerate language-table.jsx from vended data#349
Draft
daniel-jones-dev wants to merge 1 commit into
Draft
feat(snippets): regenerate language-table.jsx from vended data#349daniel-jones-dev wants to merge 1 commit into
daniel-jones-dev wants to merge 1 commit into
Conversation
1c71aae to
f8ab188
Compare
35772a9 to
585ea52
Compare
304b00e to
366cc68
Compare
73b3263 to
28cdeaf
Compare
5 tasks
1cb740a to
8326896
Compare
…ponses
Adds a single `<SupportedLanguages>` snippet that renders DeepL's
supported-languages information in MDX, drawn directly from the vended
/v3/languages responses. Doc authors drop the component anywhere they
would have hand-typed a language list and pass props that match the
API contract:
- `mode`: `inline` (default, comma-separated codes) | `bullets`
(vertical list with the language name) | `table` (the existing
interactive table on /docs/getting-started/supported-languages).
- `resource`: matches a /v3/languages resource name
(`translate_text`, `translate_document`, `voice`, `write`,
`glossary`, `style_rules`, `translation_memory`). Required for the
inline and bullets modes.
- `feature`: API feature key to filter by, exactly as it appears in
the `features` object of a response (snake_case).
- `direction`: `source` | `target`.
- `includeBeta`: include non-stable languages in the list.
Mintlify snippets are sandboxed and do not honour ES module imports,
so the per-resource JSON responses have to ship inline. The data
block lives between `// BEGIN GENERATED` / `// END GENERATED` markers
and is regenerated by `scripts/fetch_v3_languages.py`.
Script + workflow
- Folds the previous `scripts/generate_language_table.py` into
`scripts/fetch_v3_languages.py`. One script now fetches every
/v3/languages response and regenerates the inline data; the hourly
refresh workflow runs just that script.
- Adds retry-with-backoff for transient API failures (429, 5xx, and
network errors), honouring Retry-After when present.
- Validates response schemas before writing them (`resources` is a
list of objects with non-empty string `name`; each per-resource
response is a list of objects with non-empty string `lang` and
`name`). A schema mismatch raises with the exact path so a workflow
failure is actionable.
- Hard-fails if the snippet file or its BEGIN/END markers are missing.
- Discovers per-resource JSON files by walking `data/v3-languages/`,
so new resources (and manual stand-in files) appear in the snippet
automatically.
Data
- Vends a manually-maintained `data/v3-languages/translation_memory.json`
shaped like a /v3/languages response. Translation Memory is not yet
exposed by the API; once it is, the fetcher overwrites this file
with the real response and no other code has to change.
- Documents the same pattern in `data/v3-languages/README.md` as a
general "stand-in files for APIs not yet in /v3/languages" recipe.
- Picks up an API drift: `auto_detection` is now reported on
translate_document, and the new voice `spoken_terms` resource
feature is present.
MDX migrations
Replaces hand-typed language lists with the component in:
- `api-reference/improve-text.mdx` — `target_lang`, `writing_style`,
`tone` ParamFields.
- `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.
- `docs/getting-started/supported-languages.mdx` — the main table.
Each migrated list reflects the live API and includes regional
variants and beta states that the prior hand-typed lists missed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8326896 to
07c6bc5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/generate_language_table.pyreadsdata/v3-languages/*.json+data/translation-memory.jsonand rewrites thelanguageDataarray insnippets/language-table.jsxbetween// BEGIN GENERATED/// END GENERATEDmarkers. Surrounding JSX is untouched.data/translation-memory.jsonholds the small list of TM-supported codes — TM is not exposed via/v3/languages, so it stays manual.tag_handlingenabled on many languages it was previously marked false for, genericde-DE/fr-FRvariants now listed,de-CH/fr-CAcorrectly flagged as beta.Stacked on #348 — base is
refresh-v3-languages-action. Retarget after both upstream PRs merge.Source-of-truth mapping
codelangfromtranslate_text.json, uppercasednamenamefromtranslate_text.jsontranslationtrue(only languages present intranslate_text.jsonare emitted)isVarianttranslate_textusable_as_source=false && usable_as_target=trueisBetatranslate_textstatus != "stable"glossariestranslate_textfeatures containglossarytagHandlingtranslate_textfeatures containtag_handlingtextImprovementwrite.jsonstyleRulestranslate_textfeatures containstyle_rulestranslationMemorydata/translation-memory.jsonTest plan
python3 scripts/generate_language_table.py --checkexits 0 (no diff).data/translation-memory.json, re-run generator without--check, confirm only the affected rows change insnippets/language-table.jsx.mint devrenders/docs/getting-started/supported-languagesand the table includes the newDE-DE/FR-FRentries.data/v3-languages/**andsnippets/language-table.jsx.🤖 Generated with Claude Code