-
Notifications
You must be signed in to change notification settings - Fork 1
/
global.R
39 lines (31 loc) · 995 Bytes
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# A copy of this file is added to the Korrelationen app folder
#so that the app has access to it after deployment.
library(shiny)
library(shiny.i18n)
# File with translations
langList <- c("English" = "messageId",
"German" = "de")
# Module UI function
languageSelector <- function(id, label = "Language Selector") {
tagList(
selectInput(NS(id, "langSelect"), label, choices = langList),
textOutput(NS(id,"textTest"))
)
}
languageServer <- function(id, translationsPath) {
# File with translations
translator <- Translator$new(translation_json_path = translationsPath)
moduleServer(id, function(input, output, session) {
i18n <- reactive({
selected <- input$langSelect
if(input$langSelect == 'messageId') {
selected <- "en"
}
if (length(selected) > 0 && selected %in% translator$get_languages()) {
translator$set_translation_language(selected)
}
translator
})
return(i18n)
})
}