translate_vec: Translates a character vector.

View source: R/translate_vec.R

translate_vecR Documentation

Translates a character vector.

Description

Translates a character vector.

Usage

translate_vec(dataset = NULL, source.lang = "DE", target.lang = "EN",
  add.source.lang = FALSE, auth_key = NULL,
  url = "https://api.deepl.com/v2/translate?text=")

Arguments

dataset

A character vector.

source.lang

Source language. Either "detect" or one of "EN", "FR", etc.

target.lang

Target language. One of "EN", "FR", etc.

add.source.lang

A logical. If TRUE adds the preset or detected language for each translation. FALSE (default) adds nothing.

auth_key

Your API key.

url

Url to DeepL API.

Value

A character vector. If add.source.lang = TRUE a dataframe with an additional column "source_lang".

Examples

## Not run: 
  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")

## End(Not run)

paulcbauer/deeplr documentation built on April 26, 2022, 3:38 a.m.