translate: Simple machine translation of text

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/rmymemory.R

Description

Function uses MyMemory Translation API to find first available machine translation of given phrase. If machine translation is not available function returns first human translation with maximum quality score.

Usage

1
translate(txt, from = langFROM, to = langTO)

Arguments

txt

Text to translate

from

ISO2 code of origin language, e.g. "en" or "de"

to

ISO2 code of target language

Value

Function returns single string with translation.

Author(s)

Alexander Gedranovich <gedranovich@gmail.com>

References

http://mymemory.translated.net/

See Also

setpair

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Default translation from English to Russian
translate("Hello")

# Translation from English to German
translate("Hello", to="de")

# Translation from German to Spanish
translate("Hallo", from="de", to="es")

# Sentence translation
translate("To be or not to be?")

# Batch translation
txt <- c("Hello", "world", "To be or not to be?")
sapply(txt, translate, to="es")

redmode/rmymemory documentation built on May 27, 2019, 4:04 a.m.