Skip to contents

This function is a wrapper around translate_df(). It takes a dataset and creates and translates a data dictionary for it. It translates both the variable names and the value labels into one or more target languages.

Usage

translate_dict(
  dataset,
  source_lang = "en",
  target_lang = c("es", "fr", "pt"),
  translator = "wmcloud",
  formality = "more",
  glossary = NULL
)

Arguments

dataset

The input data frame to generate a dictionary from.

source_lang

The source language of the data dictionary (default is "en").

target_lang

A character vector of target language codes - can pass multiple (e.g., c("es", "fr")).

translator

The translation service to use. Passed to translate_df(). Options are "wmcloud" (default), "deepl", and "gemini". Note that "deepl" uses babelquarto and "gemini" uses mall, both of these require an API token in your environment.

formality

If using "deepl" as translator sets how formal the grammar is - accepts arguments passed to babeldown, "more"(default) but also accepts "default", "less", "prefer_more", "prefer_less"

glossary

If using "deepl" as translator allows to use a glossary for preset tranlsations, Specify the name in quotations of the glossary to be used, if any (defaults to NULL).

Value

A list containing two data frames: one for translated variable names and one for translated value labels.

Examples

if (FALSE) { # \dontrun{
translated_dictionary <- translate_dict(iris, target_lang = "es")
} # }