trans: Translate a word or phrase from one language to another

View source: R/trans.R

en2frR Documentation

Translate a word or phrase from one language to another

Description

These functions facilitate translation of fish and fisheries related terms between English and French. trans() does all the work, but the helper functions en2fr() and fr2en() are probably the easiest to work with in practice.

Usage

en2fr(
  x,
  translate = TRUE,
  case = c("none", "sentence", "lower", "upper", "title"),
  ...
)

fr2en(
  x,
  translate = TRUE,
  case = c("none", "sentence", "lower", "upper", "title"),
  ...
)

trans(
  x,
  from = "english",
  to = "french",
  case = c("none", "sentence", "lower", "upper", "title"),
  sep = "; ",
  allow_missing = FALSE,
  custom_terms = NULL
)

Arguments

x

Word or phrase to translate.

translate

Logical: perform the translation if TRUE.

case

Text case. "none" uses the value in the built-in dictionary verbatim.

...

Other arguments to be passed to trans() such as allow_missing or custom_terms.

from

Language to translate from.

to

Language to translate to.

sep

Seperator between multiple to languages.

allow_missing

Should the function return the input value if the term is missing from the dictionary? If FALSE then the function will issue a stop() statement if anything is missing.

custom_terms

An optional data frame that contains a temporary or one-off translation dictionary. Must have the column names "english" and "french". This can be useful if you want to quickly build up a set of terms to add to the dictionary before submitting them to the official package dictionary or if you have some one-off translation that you don't think would be useful to anybody else.

Examples

en2fr("Depth", TRUE)
en2fr("Depth", FALSE)
fr2en("Profondeur", TRUE)
fr2en("Profondeur", FALSE)
trans("Depth", from = "english", to = c("english", "french"))
df <- data.frame(english = c("aaa"), french = c("bbb"))
en2fr("aaa", custom_terms = df)
en2fr("Depth", TRUE, case = "none")
en2fr("Depth", TRUE, case = "upper")
en2fr("Depth", TRUE, case = "lower")
en2fr("Depth", TRUE, case = "sentence")

pbs-assess/rosettafish documentation built on Oct. 15, 2023, 3:44 p.m.