toGerman: Translate texts into German using DeepL API Pro

Description Usage Arguments Details Value References Examples

View source: R/to_lang.R

Description

toGerman translates a text from an available language into German using DeepL API Pro. Use available_languages to list all supported languages. An authentication key is required to use this service. The service costs depending on the number of translated characters.

Usage

1
2
3
4
5
6
7
8
toGerman(
  text,
  source_lang = NULL,
  split_sentences = TRUE,
  preserve_formatting = FALSE,
  get_detect = FALSE,
  auth_key = "your_key"
)

Arguments

text

character vector to be translated. Only UTF8-encoded plain text is supported. An element can contain several sentences, but should not exceed 30kbytes.

source_lang

language of the text to be translated. If parameter is.null, the API guesses the language of the source. If input is of length 1, the same source language is applied to all elements.

split_sentences

if TRUE, the translation engine splits the input into sentences. If only one sentence is translated, it is recommended to set to FALSE to prevent the engine from unintentionally splitting the sentence.

preserve_formatting

if TRUE, the translation engine tries to preserve some aspects (e.g. punctuation at the beginning and end of the sentence, upper/lower case at the beginning of the sentence) of the formatting.

get_detect

if TRUE, the language detected for the source text is included in the response.

auth_key

Authentication key.

Details

To get an authentication key, you need to register for a DeepL API Pro account (https://www.deepl.com/pro#developer).

Value

If get_detect is set to FALSE a character vector containing the translation is returned. Otherwise, a (tibble) is returned with the following columns:

References

DeepL API documentations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
# Translate a single text
toGerman("Hello world!", auth_key = "my_key")

# Translate multiple texts and return the detected language
texts <- c("Me llamo Fred.", "Je suis médecin.", "I'm from Brisbane.")
toGerman(texts, get_detect = T, auth_key = "x")


## End(Not run)

deeplr documentation built on April 28, 2021, 5:07 p.m.

Related to toGerman in deeplr...