-
Notifications
You must be signed in to change notification settings - Fork 1
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
Open
Parvati-DeepL
wants to merge
5
commits into
main
Choose a base branch
from
parvati-updates-from-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+48
−3
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae91c2e
Add guide for translating between language variants
Parvati-DeepL e7185a1
Update docs/learning-how-tos/examples-and-guides/translating-between-…
Parvati-DeepL 0837a3f
translate-between-variants updated example to json
Parvati-DeepL 540f540
Merge origin/main into parvati-updates-from-main
Parvati-DeepL 7a339d8
Merge remote changes
Parvati-DeepL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
43 changes: 43 additions & 0 deletions
43
docs/learning-how-tos/examples-and-guides/translating-between-variants.mdx
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
| 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](/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' \ | ||
| --header 'Content-Type: application/x-www-form-urlencoded' \ | ||
|
||
| --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> | ||
|
|
||
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.
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.
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.
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.
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.