i18n: Internationalization

Description Usage Arguments Value Examples

View source: R/i18n.R

Description

Simple mechanism to translate labels in a Shiny application.

Usage

1
2
3
i18n(x, translations = i18n_translations())

i18n_translations(package = packageName(parent.frame(2)))

Arguments

x

Label to translate.

translations

Either a list or a data.frame with translations.

package

Name of the package where the function is called, use NULL outside a package. It will retrieve option "i18n.<PACKAGE>" (or "i18n" if no package) to returns appropriate labels.

Value

i18n() returns a character, i18n_translations() returns a list or a data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(datamods)

# Use with an objet
my.translations <- list(
  "Hello" = "Bonjour"
)
i18n("Hello", my.translations)

# Use with options()
options("i18n" = list(
  "Hello" = "Bonjour"
))
i18n("Hello")

# With a package
options("datamods.i18n" = "fr")
i18n("Browse...", translations = i18n_translations("datamods"))
# If you call i18n() from within a function of your package
# you don't need second argument, e.g.:
# i18n("Browse...")

datamods documentation built on July 2, 2021, 5:07 p.m.