Translate character vectors via the Google Translate API

  target = "en",
  format = c("text", "html"),
  source = "",
  model = c("nmt", "base")



A character vector of text to detect language for


The target language


Whether the text is plain or HTML


Specify the language to translate from. Will detect it if left default


What translation model to use


A tibble of translatedText and detectedSourceLanguage and text of length equal to the vector of text you passed in.


You can translate a vector of strings, although if too many for one call then it will be broken up into one API call per element. This is the same cost as charging is per character translated, but will take longer.

If translating HTML set the format = "html". Consider removing anything not needed to be translated first, such as JavaScript and CSS scripts. See example on how to do this with rvest

The API limits in three ways: characters per day, characters per 100 seconds, and API requests per 100 seconds. All can be set in the API manager

See also


if (FALSE) { text <- "to administer medicine to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so" gl_translate(text, target = "ja") # translate webpages using rvest to process beforehand library(rvest) library(googleLanguageR) # translate webpages # article my_url <- "" ## in this case the content to translate is in css selector '.wcms-article-content' read_html(my_url) %>% html_node(css = ".wcms-article-content") %>% html_text %>% gl_translate(format = "html") }