-
Notifications
You must be signed in to change notification settings - Fork 11
docs: pipeline-generated pages (?, Languages, Voice) #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,147 @@ | ||||||
| --- | ||||||
| title: "Query supported languages for a resource" | ||||||
| description: "Use GET /v3/languages to fetch the languages and features available for a specific DeepL API resource, so you can build dynamic language selectors and feature checks." | ||||||
| covers: [Languages] | ||||||
| --- | ||||||
|
|
||||||
| The `/v3/languages` endpoint tells you which languages are available for a given DeepL API resource, and which optional features (formality, glossary support, tag handling, and more) each language supports. Call it at startup or on a schedule to populate language dropdowns and feature toggles in your integration, rather than hardcoding lists that go stale when DeepL adds new languages. | ||||||
|
|
||||||
| <Info> | ||||||
| `GET /v3/languages` replaces the deprecated `GET /v2/languages` endpoint. If you're still using v2, see the [migration guide](/docs/languages/migrating-from-v2-languages). | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Info box references a migration guide that may not exist The box links to |
||||||
| </Info> | ||||||
|
|
||||||
| This guide shows you how to: | ||||||
|
|
||||||
| - Fetch all languages for the `translate_text` resource | ||||||
| - Separate languages that are valid as source vs. target | ||||||
| - Check whether a specific feature (formality) is available for a language | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
||||||
| - A DeepL API key. Find yours at [your account page](https://www.deepl.com/your-account/keys). | ||||||
| - `curl` or any HTTP client. | ||||||
|
|
||||||
| If you're on the Free plan, replace `https://api.deepl.com` with `https://api-free.deepl.com` in every request below. | ||||||
|
|
||||||
| ## Step 1: Fetch languages for a resource | ||||||
|
|
||||||
| Call `GET /v3/languages` with the `resource` parameter set to the DeepL product you're building for. This example uses `translate_text`. | ||||||
|
|
||||||
| The `resource` parameter is required — pass the value that matches the DeepL product you are integrating (for example, `translate_text` for text translation). For all supported values, see the [GET /v3/languages reference](/api-reference/languages/get-languages). | ||||||
|
|
||||||
| ```sh | ||||||
| curl -X GET 'https://api.deepl.com/v3/languages?resource=translate_text' \ | ||||||
| --header 'Authorization: DeepL-Auth-Key YOUR_AUTH_KEY' | ||||||
| ``` | ||||||
|
|
||||||
| The response is a JSON array. Each object represents one language: | ||||||
|
|
||||||
| ```json | ||||||
| [ | ||||||
| { | ||||||
| "lang": "de", | ||||||
| "name": "German", | ||||||
| "status": "stable", | ||||||
| "usable_as_source": true, | ||||||
| "usable_as_target": true, | ||||||
| "features": { | ||||||
| "formality": { "status": "stable" }, | ||||||
| "glossary": { "status": "stable" }, | ||||||
| "tag_handling": { "status": "stable" } | ||||||
| } | ||||||
| }, | ||||||
| { | ||||||
| "lang": "en", | ||||||
| "name": "English", | ||||||
| "status": "stable", | ||||||
| "usable_as_source": true, | ||||||
| "usable_as_target": false, | ||||||
| "features": { | ||||||
| "glossary": { "status": "stable" }, | ||||||
| "tag_handling": { "status": "stable" } | ||||||
| } | ||||||
| }, | ||||||
| { | ||||||
| "lang": "en-US", | ||||||
| "name": "English (American)", | ||||||
| "status": "stable", | ||||||
| "usable_as_source": false, | ||||||
| "usable_as_target": true, | ||||||
| "features": { | ||||||
| "glossary": { "status": "stable" }, | ||||||
| "tag_handling": { "status": "stable" } | ||||||
| } | ||||||
| } | ||||||
| ] | ||||||
| ``` | ||||||
|
|
||||||
| Notice that `en` (English as a base code) is only valid as a source language, while `en-US` (the regional variant) is only valid as a target language. Some languages like `de` are valid in both directions. | ||||||
|
|
||||||
| <Warning> | ||||||
| Do not hardcode assumptions about language code format. Codes follow [BCP 47](https://www.rfc-editor.org/rfc/rfc5646) and can include region or script subtags of varying length. Treat the `lang` value as an opaque identifier. See [Language codes and the release process](/docs/resources/language-release-process) for details. | ||||||
| </Warning> | ||||||
|
|
||||||
| ## Step 2: Build source and target language lists | ||||||
|
|
||||||
| Filter the response by `usable_as_source` and `usable_as_target` to populate the appropriate selectors in your UI. | ||||||
|
|
||||||
| ```python | ||||||
| import urllib.request | ||||||
| import json | ||||||
|
|
||||||
| api_key = "YOUR_AUTH_KEY" | ||||||
| url = "https://api.deepl.com/v3/languages?resource=translate_text" | ||||||
|
|
||||||
| req = urllib.request.Request(url, headers={"Authorization": f"DeepL-Auth-Key {api_key}"}) | ||||||
| with urllib.request.urlopen(req) as response: | ||||||
| languages = json.load(response) | ||||||
|
|
||||||
| source_languages = [lang for lang in languages if lang["usable_as_source"]] | ||||||
| target_languages = [lang for lang in languages if lang["usable_as_target"]] | ||||||
|
|
||||||
| print("Source languages:", [lang["lang"] for lang in source_languages]) | ||||||
| print("Target languages:", [lang["lang"] for lang in target_languages]) | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 3 code snippet lacks standalone context The Step 3 Python snippet references
Suggested change
|
||||||
| ``` | ||||||
|
|
||||||
| Example output (truncated): | ||||||
|
|
||||||
| ```text | ||||||
| Source languages: ['de', 'en', 'es', 'fr', ...] | ||||||
| Target languages: ['de', 'en-GB', 'en-US', 'es', 'fr', ...] | ||||||
| ``` | ||||||
|
|
||||||
| ## Step 3: Check feature availability for a language pair | ||||||
|
|
||||||
| Before enabling a feature in your UI (for example, a formality selector), check that the target language supports it. Features appear as keys in the `features` object. | ||||||
|
|
||||||
| ```python | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 4 marked optional in heading but not skippable in flow Including '(optional)' in a step heading is a valid pattern, but readers may not know whether skipping Step 4 affects Next Steps or later code. Since Step 4 is genuinely self-contained and doesn't affect Steps 2-3, the current placement is fine, but consider adding one sentence explicitly saying: 'Skipping this step has no effect on the filters built in Steps 2 and 3.' Suggested fix: Add after the Step 4 heading or intro sentence: 'This step is independent of Steps 2 and 3; skip it if you only need stable languages.' |
||||||
| def supports_feature(language, feature_name): | ||||||
| return feature_name in language.get("features", {}) | ||||||
|
|
||||||
| # Find German in the target language list | ||||||
| german = next((lang for lang in target_languages if lang["lang"] == "de"), None) | ||||||
|
|
||||||
| if german and supports_feature(german, "formality"): | ||||||
| print("German supports formality; show the formality selector") | ||||||
| else: | ||||||
| print("German does not support formality; hide the selector") | ||||||
| ``` | ||||||
|
|
||||||
| For a complete picture of which languages must support a feature (source, target, or both) for a given resource, call `GET /v3/languages/resources`. See [Using the Languages API](/docs/languages/using-the-languages-api) for details on that endpoint. | ||||||
|
|
||||||
| ## Step 4: Include beta languages (optional) | ||||||
|
|
||||||
| By default, the endpoint returns only stable languages. To also include beta languages, add `include=beta` to your request: | ||||||
|
|
||||||
| ```sh | ||||||
| curl -X GET 'https://api.deepl.com/v3/languages?resource=translate_text&include=beta' \ | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Next steps link text inconsistent with target page title The Next Steps entry reads 'Using the Languages API' but is described as covering 'the full GET /v3/languages and GET /v3/languages/resources endpoint reference, including all response fields and feature semantics.' If that target page is reference material, the link text should signal that (e.g. 'GET /v3/languages reference'). If it is a how-to or explanation, the description is mixing reference framing into a narrative link. Clarify what type of page it is and align the link text and description accordingly. |
||||||
| --header 'Authorization: DeepL-Auth-Key YOUR_AUTH_KEY' | ||||||
| ``` | ||||||
|
|
||||||
| Languages returned with `"status": "beta"` are functional but not yet stable. Check the `status` field before displaying them to end users, since beta languages may change. | ||||||
|
|
||||||
| ## Next steps | ||||||
|
|
||||||
| - [Using the Languages API](/docs/languages/using-the-languages-api) covers the full `GET /v3/languages` and `GET /v3/languages/resources` endpoint reference, including all response fields and feature semantics | ||||||
| - [Supported languages](/docs/getting-started/supported-languages) lists the currently supported languages as a static reference table | ||||||
| - [Migrating from v2/languages](/docs/languages/migrating-from-v2-languages) if you're updating an existing integration | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frontmatter description slightly exceeds recommended specificity for action orientation
The description is good and action-oriented. Minor improvement: 'so you can build dynamic language selectors and feature checks' is slightly use-case-oriented marketing framing. Consider tightening to focus on the action: 'Learn how to call GET /v3/languages to fetch available languages and feature flags for a DeepL API resource, filter by source/target direction, and check per-language feature support.'