This Shiny module gets language that's currently selected in the language selector. It needs to be used in the Server to save the currently active (selected) language in a reactive. This reactive can then be passed to the i_ function to translate the text.

langSelector(input, output, session, i18n = NULL, showSelector = TRUE)

Arguments

i18n

List of language configurations; can only be set for i_. Options that can be set are:

defaultLang Default language used in Shiny app; default = "en"

availableLangs Language that can be chosen for translation in Shiny app; there are currently 15 Available languages (see below); defaults to all.

localeDir Directory to yaml files which contain custom keyword translations; default = "locale"

fallbacks List of fallback languages if translation for a word is not found in desired language; defaults to Default fallbacks (see below)

queryParameter String to define query parameter if language to be set through URL; default = "lang"

showSelector

Boolean to specify if language selector should be displayed or not. Even if selector is not displayed, language can always be set by query parameter; default = "lang"

Value

String of language code of currently selected languages.

Available languages

There are currently 15 languages available for translation:

codelanguage
arArabic
caCatalan
daDanish
deGerman
enEnglish
esSpanish
frFrench
heHebrew
hiHindi
itItalian
ptPortuguese
pt_BRPortuguese (Brazil)
ruRussian
svSwedish
zh_CNChinese

Default fallbacks

If no fallback languages are specified, translations automatically fall back onto the following languages.

original languagefallback language
espt
ptes
frpt
denl
nlde

Examples

if (FALSE) { i18n <- list( defaultLang = "en", availableLangs = c("en", "de") ) lang <- callModule(langSelector,"lang", i18n = i18n, showSelector = TRUE) }