knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The DeepL Translator made headlines for providing better translations than Google etc. deeplr
is a quick & dirty coded package that contains functions - translate_vec()
and translate_df()
- that access the DeepL API. I was inspired by the translateR package package.
To access the API you need to get your own API key from deeplr: https://www.deepl.com/api-contact.html.
Beware of the API request limits. See https://www.deepl.com/api-reference.html.
# Development version # install.packages("devtools") devtools::install_github("paulcbauer/deeplr")
You can feed translate_vec()
with a single string, a vector of strings (class "character"). You can feed translate_df()
with a dataframe that contains a column of class "character".
# Load the package library(deeplr) # Translate a single string/character vector dat <- c("La seule facon de savoir ce qui se passe est de perturber le systeme.", "The whole problem with the world is that fools are always so certain of themselves") # Without language detection and without adding set/detected source language. translate_vec(dataset = dat, source.lang = "EN", target.lang = "DE", auth_key = "enter you auth key here") dat <- c("A dog.", "Un chien.", "Un perro.", "Un cane.", "Een hond.") # With language detection and with adding set/detected source language. translate_vec(dataset = dat, source.lang = "detect", target.lang = "DE", add.source.lang = TRUE, auth_key = "enter you auth key here") # Translate a column in a dataframe dat <- data.frame(text = c("La seule facon de savoir ce qui se passe est de perturber le systeme.", "The whole problem with the world is that fools are always so certain of themselves")) # Without language detection and without adding set/detected source language. translate_df(dataset = dat, column.name = "text", source.lang = "EN", target.lang = "DE", auth_key = "enter you auth key here") dat <- data.frame(text = c("A dog.", "Un chien.", "Un perro.", "Un cane.", "Een hond.")) # With language detection and with adding set/detected source language. translate_df(dataset = dat, column.name = "text", source.lang = "detect", target.lang = "DE", add.source.lang = TRUE, auth_key = "enter you auth key here") # well...
License: CC BY-NC-SA 4.0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.