-
Notifications
You must be signed in to change notification settings - Fork 7
Added guide for translating between language variants #217
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
Changes from 1 commit
ae91c2e
e7185a1
0837a3f
540f540
7a339d8
16e1ea8
3585cf4
f215c29
934597f
933ad29
67bef75
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,43 @@ | ||
| --- | ||
| title: "Translating Between Language Variants" | ||
| description: "Learn how to translate between variants of the same language, such as en-US to en-GB" | ||
| public: true | ||
| --- | ||
|
|
||
| You can use the DeepL API to translate between variants of the same language (for example, `pt-PT` to `pt-BR` or `en-US` to `en-GB`) using several methods: | ||
|
|
||
| - **[Write/Rephrase endpoint](/api-reference/improve-text)**: Rephrases text into the target language variant. | ||
|
|
||
| - **[Style rules](/api-reference/style-rules)**: Create a custom style rule and apply it using the [style_id](https://developers.deepl.com/api-reference/translate/request-translation#body-style-id) parameter. | ||
|
|
||
| <Info>Both glossaries and style rules are unique to each of DeepL's global data centers and are not shared between them. Clients using the api-us.deepl.com endpoint will not be able to access glossaries or style rules created in the UI at this time.</Info> | ||
|
|
||
| - **[Custom instructions](/api-reference/translate/request-translation#body-custom-instructions)**: Add instructions like "translate to British English" to your `/translate` request. You can specify up to 10 custom instructions, each with a maximum of 300 characters. | ||
|
|
||
| ## Example: Converting American English to British English | ||
|
|
||
| ```bash Example request | ||
| curl --location 'https://api.deepl.com/v2/translate' \ | ||
|
Member
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. I've seen this guidance before, but just to double check: Have we confirmed with research that both of these approaches (1) write and 2) translate with custom instructions) are qualitatively good? E.g. the prompts for the custom instruction model seem very short to me, naively (without knowing) I'd expect write to do a better to job here.
Collaborator
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. hey! I don't think this has been confirmed with research. write/rephrase was documented previously to be used for this use case instead, but it will consistently rephrase text, and the customizations available in the UI like 'corrections only' mode to prevent this aren't available in the API. so Ming initially suggested custom prompts as a workaround. we tested custom instructions a lot for all trails using these types of prompts and it consistently worked. given that it works and write/rephrase is already up as a suggestion for this publicly, figured it would be fine to include this as well. that said if you want me to start a thread with research about it, I'm happy to.
Member
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. @Parvati-DeepL could you start a thread with research and link it here? I think this guidance came from them at some point, but I couldn't find a source, so it could be worth double checking. That said, I think this is fine to merge/not a blocking point, as we've observed that it works across a variety of use cases
Collaborator
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. https://deeplgmbh.slack.com/archives/C013E3SRHDG/p1767795519854989 yes! linked here. I also tried to merge the changes in from yours @shirgoldbird , telling the Agent to follow that guide as well as the sub-agent for Claude. LMK if now it looks good @JanEbbing . @shirgoldbird is OOO but did want to get this merged in so requesting a re-review of this as a whole. |
||
| --header 'Content-Type: application/x-www-form-urlencoded' \ | ||
|
Member
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. Nit: I'd prefer if we consistently used |
||
| --header 'Accept: application/json' \ | ||
| --header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \ | ||
| --data-urlencode 'text=I went to the pharmacy to get some acetaminophen.' \ | ||
| --data-urlencode 'target_lang=en-GB' \ | ||
| --data-urlencode 'model_type=quality_optimized' \ | ||
| --data-urlencode 'custom_instructions=["translate to British English", "only replace words that would be different"]' | ||
| ``` | ||
|
|
||
| ```json Example response | ||
| { | ||
| "translations": [ | ||
| { | ||
| "detected_source_language": "EN", | ||
| "text": "I went to the chemist to get some paracetamol.", | ||
| "model_type_used": "quality_optimized" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| <Tip>The custom instructions convert American English terms ("pharmacy", "acetaminophen") to British English equivalents ("chemist", "paracetamol") while preserving sentence structure.</Tip> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.