translate | R Documentation |
Translates UTF-8 encoded plain text between supported languages using the DeepL API Pro. A list of supported source and target languages is available at https://developers.deepl.com/docs/getting-started/supported-languages. An authentication key is required to use this service. Charges may apply based on the number of characters translated.
translate(
text,
target_lang = "EN",
source_lang = NULL,
split_sentences = TRUE,
preserve_formatting = FALSE,
get_detect = FALSE,
context = NULL,
model_type = NULL,
formality = NULL,
glossary_id = NULL,
auth_key
)
text |
Character vector. The text(s) to translate. Each element can contain multiple sentences but must not exceed 30 kB. Only UTF-8 plain text is supported. |
target_lang |
Character vector. Target language(s) for translation. If length 1, all texts are translated into the same language. |
source_lang |
Character vector or |
split_sentences |
Logical. If |
preserve_formatting |
Logical. If |
get_detect |
Logical. If |
context |
Optional. Contextual text to improve translation quality, especially for short or ambiguous inputs. Context is not translated and does not count toward character limits. |
model_type |
Optional. Specifies the DeepL model to use:
|
formality |
Optional. Controls the formality level of the translation (only supported for certain target languages):
|
glossary_id |
Optional. Glossary ID for translation. Must match the language pair and requires |
auth_key |
Character. Your DeepL API authentication key. If missing, the function uses
the |
Register for a DeepL API Pro key at https://www.deepl.com/pro#developer.
Only texts passed via the text
argument count toward your monthly quota.
If get_detect = FALSE
, returns a character vector of translated texts.
If get_detect = TRUE
, returns a tibble with:
translation
– Translated text.
source_lang
– Detected or provided source language.
DeepL API Documentation — Translate
list_glossaries
## Not run:
translate("I like to translate texts.", target_lang = "DE")
translate(
c("I like to translate texts.", "Ich übersetze gerne Texte."),
target_lang = "FR"
)
translate("I like to translate texts.", target_lang = c("FR", "DE", "IT"))
translate(
c("I like to translate texts.", "Ich übersetze gerne Texte."),
target_lang = c("FR", "IT")
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.