gl_translate: Translate the language of text within a request

View source: R/translate.R

gl_translateR Documentation

Translate the language of text within a request

Description

Translate character vectors via the Google Translate API.

Usage

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

Arguments

t_string

Character vector of text to translate

target

The target language code

format

Whether the text is plain text or HTML

source

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

model

Translation model to use

Details

You can translate a vector of strings; if too many for one call, it will be broken up into one API call per element. The API charges per character translated, so splitting does not change cost but may take longer.

If translating HTML, set format = "html". Consider removing anything not needed to be translated first, such as JavaScript or CSS.

API limits: characters per day, characters per 100 seconds, and API requests per 100 seconds. These can be configured in the API manager: https://console.developers.google.com/apis/api/translate.googleapis.com/quotas

Value

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

See Also

https://cloud.google.com/translate/docs/reference/translate

Other translations: gl_translate_detect(), gl_translate_document(), gl_translate_languages()


googleLanguageR documentation built on Aug. 25, 2025, 1:12 a.m.