Skip to content

Generate supported-languages table from /v3/languages#395

Open
lilkraftwerk wants to merge 8 commits into
mainfrom
docs/language-table-from-v3
Open

Generate supported-languages table from /v3/languages#395
lilkraftwerk wants to merge 8 commits into
mainfrom
docs/language-table-from-v3

Conversation

@lilkraftwerk

@lilkraftwerk lilkraftwerk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Language-support info across the docs was hand-maintained and drifting from what the API reports. This PR makes it generated from GET /v3/languages.

One script per target, plus a parent that updates everything:

node scripts/update-language-docs.mjs <api-key>
Script Target
generate-language-table.mjs languages table on Languages supported
generate-voice-languages.mjs Voice API support matrix + the input/target lists on the service-specification page
generate-formality-lists.mjs formality target-language sentences on translate and document
generate-write-lists.mjs target_lang / writing_style / tone lists on improve-text
generate-style-rules-lists.mjs style-rules language mentions (custom_instructions note, supported-languages callout)

Generated content sits between BEGIN/END GENERATED markers; everything outside stays hand-written. Each script also runs standalone. The API key is passed as an argument, never stored. Set DEEPL_SERVER_URL to run against a mock. The OpenAPI spec is untouched.

Notable data changes (all now match the live API)

  • supported-languages table: tag handling shown for all translation languages, new DE-DE/FR-FR variants, DE-CH/FR-CA corrected, EN/ZH/PT-PT gain text improvement
  • formality: translate and document pages previously disagreed (ES-419 in one, missing in the other); both now list the API's set incl. base PT, DE-DE, FR-FR and the beta DE-CH/FR-CA variants
  • improve-text: adds base en/pt and zh-Hant per the API; writing_style/tone lists gain base pt
  • voice: matrix content unchanged (it was accurate); the service-specification lists gain the beta languages hi, ms, ta and base en/zh as text targets

Regenerating after future API changes (for example new style-rules languages) is one command and a reviewable diff.

Automation

A scheduled workflow (sync-language-docs.yml, daily + manual dispatch) reruns the generators and opens a PR when /v3/languages changed. The git/PR logic lives in scripts/open-sync-pr.sh (CI-only). Needs a DEEPL_API_KEY repo secret; use a dedicated, cost-capped key. Note: PRs opened with the built-in token do not trigger other workflows, so CI on the bot PR needs a manual nudge (or a PAT/App token later).

Replace the hand-maintained languageData array in the language table
snippet with output generated from GET /v3/languages, and add the
generator script. The array now sits between BEGIN/END GENERATED
markers; run node scripts/generate-language-table.mjs to refresh it.
@mintlify

mintlify Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
deepl-c950b784 🟢 Ready View Preview Jul 9, 2026, 7:32 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@lilkraftwerk lilkraftwerk marked this pull request as ready for review July 9, 2026 07:56
Split the generator into one script per target with a parent that runs
all of them (scripts/update-language-docs.mjs). New generated blocks:
the Voice API language matrix and its service-specification lists, the
formality sentences on translate and document, the target_lang,
writing_style and tone lists on improve-text, and the style-rules
language mentions. Generated blocks sit between BEGIN/END GENERATED
markers; everything outside them stays hand-written.
Formality and write language lists are now grouped by base language and
sorted alphabetically. Shared joinList handles one- and two-item lists,
the marker regex escapes ids and anchors on the trailing space, the
parent script reports partial-update state on failure, and the voice
generator warns if a target-only language would be missing from the
matrix. Restores the pt-PT scope caveat on the service specification
page and the final conjunction in the style-rules callout.
Tests run with Node's built-in runner (node --test scripts/*.test.mjs),
covering joinList edge cases, groupByBase grouping and ordering, the
marker-replacement core (extracted as pure replaceGeneratedBlock),
voice matrix symbols, and the grouped bullet renderer. A GitHub
workflow runs them on PRs touching scripts/.
Scheduled (plus manual dispatch) workflow that reruns the generators
against /v3/languages and opens a PR when anything changed. The git and
PR logic lives in scripts/open-sync-pr.sh, which refuses to run outside
CI. Requires a DEEPL_API_KEY repo secret; use a dedicated cost-capped
key. Repeated drift updates the same bot branch and PR.
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