R Interface to Yandex Translate API. Yandex Translate is a statistical machine translation system. The system translates separate words, complete texts, and webpages. This package can be used to detect language from text and to translate it to supported target language.
To install from CRAN repository:
install.packages("RYandexTranslate")
To install from github:
library(devtools) install_github("mukul13/RYandexTranslate")
To get free API key, sign up here
api_key="YOUR API KEY"
To list all functions supported by RYandexTranslate package
library(RYandexTranslate) ls("package:RYandexTranslate")
#>"detect_language" "get_translation_direction" "translate"
To get a list of translation directions supported by the service
directions=get_translation_direction(api_key) head(directions$dirs)
#>"az-ru" "be-bg" "be-cs" "be-de" "be-en" "be-es"
To detect the language of the specified text
data=detect_language(api_key,text="how are you?") data
#>"en"
To translate text to the specified language
data=translate(api_key,text="how are you?",lang="en-hi") data
#>$lang #>[1] "en-hi" #> #>$text #>[1] "आप कैसे हैं?"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.