Adds a custom translation for a key in one or more locales. Custom translations take precedence over built-in translations, allowing users to override defaults or add study-specific terminology.
Details
Custom translations persist for the duration of the R session. They are stored separately from built-in translations and take precedence when translating keys.
This is particularly useful for:
Study-specific terminology
Regulatory-specific terms not in the default dictionary
Correcting or adjusting default translations for specific contexts
Examples
# Add a custom translation
add_translation(
"study_drug",
c(en = "DrugX 100mg", de = "MedikamentX 100mg")
)
tr("study_drug")
#> [1] "DrugX 100mg"
# [1] "DrugX 100mg"
tr("study_drug", locale = "de")
#> [1] "MedikamentX 100mg"
# [1] "MedikamentX 100mg"
# Override existing translation
add_translation(
"treatment", c(en = "Active Treatment", de = "Aktive Behandlung")
)
