Build an offline display dictionary

forma_dictionary.RdEach row identifies one label by its context, stable ID and language.
The column named variable holds the context for compatibility with
forma_labels(). A data frame may use context as an alias.
Different keys may share a display label. Metadata describes who supplied
the wording and its review status. These fields accept project-specific,
non-empty text. Supplying a dictionary never changes the built-in table.
Usage
forma_dictionary(
x = NULL,
lang = NULL,
context = "stat",
source = "user",
review_status = "unreviewed"
)Arguments
- x
A table with
variable,id,langandlabel, or a named character vector of labels keyed by ID. Omit this argument to retrieve the built-in statistical terms.- lang
Language tag for a named vector, e.g.
"zh-Hans".- context
Context for a named vector, e.g. a variable name, a plot component or
"stat"for ggforma statistical terms.- source
Source of the wording when the input lacks this column.
- review_status
Review status when the input lacks this column.
Details
The seed dictionary contains eight IDs in the stat context:
count, percentage, observed, expected, residual, total, source and pearson_residual. Its
English, Chinese, Japanese, Korean and Arabic rows are AI-assisted
drafts pending editorial and fluent-reader review.
Supply reviewed entries to override individual terms.
For CSV exchange, use utils::write.csv(d, path, row.names = FALSE,
fileEncoding = "UTF-8"). Read with utils::read.csv(path,
fileEncoding = "UTF-8", colClasses = "character", na.strings = character())
and call forma_dictionary() to validate. These options preserve
leading zeros, literal "NA" keys, metadata and multilingual labels.
Examples
terms <- forma_dictionary()
sites <- forma_dictionary(c(N = "North", S = "South"),
lang = "en", context = "site",
source = "Site registry", review_status = "reviewed")
forma_translate(c("N", "S"), "en-GB", "site", sites)
#> [1] "North" "South"