translate2 | R Documentation |
translate2
translates texts between different languages using DeepL API Free.
Use available_languages2
to list all supported languages. An authentication key
is required to use this service. With the DeepL API Free package, developers can translate
up to 500,000 characters per month for free.
translate2(
text,
target_lang = "EN",
source_lang = NULL,
split_sentences = TRUE,
preserve_formatting = FALSE,
get_detect = FALSE,
auth_key = "your_key"
)
text |
character vector to be translated. Only UTF8-encoded plain text is supported. An element can contain several sentences, but should not exceed 30kbytes. |
target_lang |
target language of the translation. If input is of length 1, all elements are translated into the same language. |
source_lang |
language of the text to be translated. If parameter |
split_sentences |
if |
preserve_formatting |
if |
get_detect |
if |
auth_key |
Authentication key. |
To get an authentication key, you need to register for a DeepL API Free account (https://www.deepl.com/pro#developer).
If get_detect
is set to FALSE
a character vector
containing the
translation is returned. Otherwise, a (tibble
) is returned with the following columns:
translation
the translated text.
source_lang
detected or specified language of the input text.
## Not run:
# Translate a single text
translate2("I like to translate texts.", target_lang = "DE", auth_key = "x")
# Translate multiple texts into one target language
texts <- c("I like to translate texts.", "Ich übersetze gerne Texte.")
translate2(texts, target_lang = "FR", auth_key = "x")
# Translate a single text into multiple target languages
translate2("I like to translate texts.", target_lang = c("FR", "DE", "IT"), auth_key = "x")
# Translate multiple texts into different languages
texts <- c("I like to translate texts.", "Ich übersetze gerne Texte.")
translate2(texts, target_lang = c("FR", "IT"), auth_key = "x")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.