Translate display keys offline

forma_translate.RdResolve whole keys after computing chart statistics. This function never searches and replaces words inside free text, code, formulas or markup. Contexts separate categories, axis labels, titles and statistical terms. The exact language is tried first, followed by each parent tag. At each tag, user entries take precedence over built-in entries for the same key.
Usage
forma_translate(
x,
lang = NULL,
context = "stat",
dictionary = NULL,
missing = c("keep", "warn", "error", "NA"),
diagnostics = FALSE,
type = "text"
)Arguments
- x
Stable character IDs or a factor. Formula, expression, symbol and call objects are returned verbatim when diagnostics are off. An
I()character vector is also protected. For character input that contains source code, a formula or markup, settypeexplicitly.- lang
One language tag, or
NULLto keep the input labels.- context
One context, or one per ID. The default
"stat"selects the built-in statistical terms.- dictionary
An optional local table accepted by
forma_dictionary().- missing
What to do with an unmatched text key: keep the ID, warn and keep the ID, raise an error, or return a missing label (
"NA"). An inputNAstays missing.- diagnostics
Return a row per key with the requested and matched tag, label, origin, source, review status and match status. For protected R expressions the diagnostic label is a printable representation.
- type
One of
"text","formula","code"or"markup", or one per input. Only text keys are looked up.
Value
A character vector in input order, the original protected object,
or a diagnostic data frame. Match statuses are exact,
fallback, missing, missing_input,
protected and disabled.
Examples
forma_translate(c("observed", "expected"), "ja")
#> [1] "観測値" "期待値"
forma_translate(c("count", "absent"), "ar-EG", diagnostics = TRUE)
#> id context lang matched_lang label origin
#> 1 count stat ar-eg ar العدد builtin
#> 2 absent stat ar-eg <NA> absent <NA>
#> source review_status status
#> 1 ggforma AI-assisted seed glossary provisional fallback
#> 2 <NA> <NA> missing
forma_translate(expression(sqrt(x)), "ar")
#> expression(sqrt(x))