Skip to content

feat(snippets): regenerate language-table.jsx from vended data#349

Draft
daniel-jones-dev wants to merge 1 commit into
refresh-v3-languages-actionfrom
autogen-language-tables
Draft

feat(snippets): regenerate language-table.jsx from vended data#349
daniel-jones-dev wants to merge 1 commit into
refresh-v3-languages-actionfrom
autogen-language-tables

Conversation

@daniel-jones-dev
Copy link
Copy Markdown
Member

Summary

  • New scripts/generate_language_table.py reads data/v3-languages/*.json + data/translation-memory.json and rewrites the languageData array in snippets/language-table.jsx between // BEGIN GENERATED / // END GENERATED markers. Surrounding JSX is untouched.
  • data/translation-memory.json holds the small list of TM-supported codes — TM is not exposed via /v3/languages, so it stays manual.
  • Hourly workflow (added in chore(ci): refresh vended v3/languages responses hourly #348) now runs the generator after fetching, so refreshed responses and the rendered table land in the same PR.
  • First-run regeneration brings the table back in sync with the live API: e.g. tag_handling enabled on many languages it was previously marked false for, generic de-DE / fr-FR variants now listed, de-CH / fr-CA correctly flagged as beta.

Stacked on #348 — base is refresh-v3-languages-action. Retarget after both upstream PRs merge.

Source-of-truth mapping

JSX field Source
code lang from translate_text.json, uppercased
name name from translate_text.json
translation always true (only languages present in translate_text.json are emitted)
isVariant translate_text usable_as_source=false && usable_as_target=true
isBeta translate_text status != "stable"
glossaries translate_text features contain glossary
tagHandling translate_text features contain tag_handling
textImprovement language is in write.json
styleRules translate_text features contain style_rules
translationMemory code is in data/translation-memory.json

Test plan

  • python3 scripts/generate_language_table.py --check exits 0 (no diff).
  • Edit data/translation-memory.json, re-run generator without --check, confirm only the affected rows change in snippets/language-table.jsx.
  • mint dev renders /docs/getting-started/supported-languages and the table includes the new DE-DE / FR-FR entries.
  • Manually dispatch the refresh workflow (after chore(ci): refresh vended v3/languages responses hourly #348 merges) and confirm the auto-PR includes both data/v3-languages/** and snippets/language-table.jsx.

🤖 Generated with Claude Code

@daniel-jones-dev daniel-jones-dev marked this pull request as draft May 19, 2026 12:26
@daniel-jones-dev daniel-jones-dev force-pushed the refresh-v3-languages-action branch from 1c71aae to f8ab188 Compare May 19, 2026 12:31
@daniel-jones-dev daniel-jones-dev force-pushed the autogen-language-tables branch 2 times, most recently from 35772a9 to 585ea52 Compare May 19, 2026 13:01
@daniel-jones-dev daniel-jones-dev force-pushed the refresh-v3-languages-action branch from 304b00e to 366cc68 Compare May 20, 2026 08:47
@daniel-jones-dev daniel-jones-dev force-pushed the autogen-language-tables branch 4 times, most recently from 73b3263 to 28cdeaf Compare May 22, 2026 09:44
@daniel-jones-dev daniel-jones-dev force-pushed the autogen-language-tables branch 2 times, most recently from 1cb740a to 8326896 Compare May 22, 2026 10:00
…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>
@daniel-jones-dev daniel-jones-dev force-pushed the autogen-language-tables branch from 8326896 to 07c6bc5 Compare May 22, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant