i18n {datamods}R Documentation

Internationalization

Description

Simple mechanism to translate labels in a Shiny application.

Usage

i18n(x, translations = i18n_translations())

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

set_i18n(value, packages = c("datamods", "esquisse"))

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

Value to set for translation. Can be:

  • single character to use a supported language ("fr", "mk", "al", "pt" for esquisse and datamods packages).

  • a list with labels as names and translations as values.

  • a data.frame with 2 column: label & translation.

  • path to a CSV file with same structure as for data.frame above.

packages

Name of packages for which to set i18n, default to esquisse and datamods

Value

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

Examples

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...")

[Package datamods version 1.5.1 Index]