From 2271c24b19f4c8ec496da1e57590e6a6f8a02ae1 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Tue, 16 Nov 2021 12:21:55 +0100 Subject: [PATCH] dutch translations --- .gitignore | 1 + global.R | 31 +++++++++++------ server.R | 86 ++++++++++++++++++++++++++---------------------- translations.txt | 45 +++++++++++++++++++++++++ ui.R | 16 ++++----- 5 files changed, 122 insertions(+), 57 deletions(-) create mode 100644 translations.txt diff --git a/.gitignore b/.gitignore index 65bc70d..f20a8b8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .Ruserdata *.Rproj .DS_Store +bk_2019.rds diff --git a/global.R b/global.R index 732c0b8..5d1d596 100644 --- a/global.R +++ b/global.R @@ -18,7 +18,17 @@ library(cleaner) library(scales) library(ggiraph) -specialties <- read_csv("specialties.csv") +specialties <- read_csv("specialties.csv", lazy = FALSE) + +trsns <- read_tsv("translations.txt", lazy = FALSE) +# to do: make system settings dependent +trnslt <- function(english, new_lang = "nl", file = trsns) { + if (english %in% trsns[, 1, drop = TRUE]) { + trsns[match(english, trsns[, 1, drop = TRUE]), new_lang, drop = TRUE] + } else { + english + } +} specialties <- specialties %>% mutate(specialty_shiny = if_else(specialty != "Outpatients", paste0(specialty, " (", str_replace_all(specialism, ";", ", "), ")"), "Outpatients"), @@ -37,13 +47,13 @@ radar_data <- radar_data %>% mutate(specialty = if_else(is.na(specialty), "NO SPECIALTY GIVEN", specialty), specialty_shiny = if_else(is.na(specialty_shiny), "NO SPECIALTY GIVEN", specialty_shiny), name = mo_name(mo), - FLC = OXAC) %>% + FLC = OXA) %>% left_join(pathogens) -lab_ab <- c("CFCC", "CFCL", "CFOC", "CFSC", "CFTC", "COCL", "GEHI", "QUDA") +# lab_ab <- c("CFCC", "CFCL", "CFOC", "CFSC", "CFTC", "COCL", "GEHI", "QUDA") radar_data <- radar_data %>% - select_at(vars(!contains(lab_ab))) %>% + # select_at(vars(!contains(lab_ab))) %>% rename_if(is.rsi, function(x) ifelse(is.na(suppressWarnings(as.ab(x))), x, suppressWarnings(as.ab(x)))) %>% @@ -51,13 +61,14 @@ radar_data <- radar_data %>% radar_data <- radar_data %>% mutate(CRO = if_else(is.na(CRO) & !is.na(CTX), CTX, CRO)) - -radar_data_first <- radar_data %>% - filter_first_isolate(col_patient_id = "patientid", episode_days = 365) %>% - mutate(mo = as.mo(mo, Becker = TRUE)) +suppressMessages( + radar_data_first <- radar_data %>% + filter_first_isolate(col_patient_id = "patientid", episode_days = 365, info = FALSE) %>% + mutate(mo = as.mo(mo, Becker = TRUE)) +) -intrinsic_info <- intrinsic_resistant %>% +intrinsic_info <- AMR::intrinsic_resistant %>% mutate(mo = as.mo(microorganism), intrinsic_r = TRUE) @@ -71,4 +82,4 @@ download_box <- function(exportname, plot) { ggsave(file, plot = plot, device = "png", width = 8) } ) -} \ No newline at end of file +} diff --git a/server.R b/server.R index e8b86f9..67d5f4b 100644 --- a/server.R +++ b/server.R @@ -72,14 +72,14 @@ server <- function(input, output, session) { width = NULL, height = 500, tabPanel( - title = "Positive & negative cultures", + title = trnslt("Positive & negative cultures"), div( style = "position: absolute; left: 0.5em; bottom: 0.5em;", dropdown( radioGroupButtons( inputId = "box2.1_group", - label = "Select group", - choiceNames = c("All", "Year", "Gender", "Department", "Specialty", "Specialty code", "ICU status", "Clinical status", "Outward status"), + label = trnslt("Select group"), + choiceNames = c(trnslt("All"), trnslt("Year"), trnslt("Gender"), trnslt("Department"), trnslt("Specialty"), trnslt("Specialty code"), trnslt("ICU status"), trnslt("Clinical status"), trnslt("Outward status")), choiceValues = c("group_all", "year", "gender", "department", "specialty", "specialism", "is_icu", "is_clinical", "is_outward"), selected = "group_all", direction = "vertical", @@ -92,7 +92,7 @@ server <- function(input, output, session) { div( style = "position: absolute; right: 3.5em; bottom: 0.5em;", dropdown( - downloadButton(outputId = "down_box_pos_neg", label = "Download plot"), + downloadButton(outputId = "down_box_pos_neg", label = trnslt("Download plot")), size = "xs", icon = icon("download", class = "opt"), up = TRUE @@ -111,8 +111,8 @@ server <- function(input, output, session) { dropdown( radioGroupButtons( inputId = "box2.3_group", - label = "Select group", - choiceNames = c("All", "Year", "Gender", "Department", "Specialty", "Specialty code", "ICU status", "Clinical status", "Outward status"), + label = trnslt("Select group"), + choiceNames = c(trnslt("All"), trnslt("Year"), trnslt("Gender"), trnslt("Department"), trnslt("Specialty"), trnslt("Specialty code"), trnslt("ICU status"), trnslt("Clinical status"), trnslt("Outward status")), choiceValues = c("group_all", "year", "gender", "department", "specialty", "specialism", "is_icu", "is_clinical", "is_outward"), selected = "group_all", direction = "vertical" @@ -127,12 +127,12 @@ server <- function(input, output, session) { dropdown( sliderTextInput( inputId = "box2.4_top", - label = "Use slider to select by count", + label = trnslt("Use slider to select by count"), choices = seq(0, n_distinct(radar_data$mo), 10), selected = c(0, 10) ), size = "xs", - label = "Select top ...", + label = trnslt("Select top ..."), up = TRUE) ), div( @@ -140,13 +140,13 @@ server <- function(input, output, session) { dropdown( radioGroupButtons( inputId = "box2.3_pathogen", - label = "Select pathogen group", + label = trnslt("Select pathogen group"), choiceNames = c("all", "definite", "probable", "improbable"), choiceValues = c(0, 1, 2, 3), selected = 0 ), size = "xs", - label = "Pathogens", + label = trnslt("Pathogens"), up = TRUE )), div( @@ -154,13 +154,13 @@ server <- function(input, output, session) { dropdown( selectInput( inputId = "box2.5_search", - label = "Search and select isolates", + label = trnslt("Search and select isolates"), choices = mo_fullname(unique(radar_data$mo)[which(!is.na(unique(radar_data$mo)))]), multiple = TRUE ), size = "xs", - label = "Search isolates", + label = trnslt("Search isolates"), up = TRUE )), div( @@ -173,13 +173,13 @@ server <- function(input, output, session) { selected = 365 ), size = "xs", - label = "Define first isolate guidelines", + label = trnslt("Define first isolate guidelines"), up = TRUE )), div( style = "position: absolute; right: 3.5em; bottom: 0.5em;", dropdown( - downloadButton(outputId = "down_box_patho", label = "Download plot"), + downloadButton(outputId = "down_box_patho", label = trnslt("Download plot")), size = "xs", icon = icon("download", class = "opt"), up = TRUE @@ -193,14 +193,14 @@ server <- function(input, output, session) { ) ), tabPanel( - title = "First isolates per episode", + title = trnslt("First isolates per episode"), div( style = "position: absolute; left: 0.5em; bottom: 0.5em;", dropdown( radioGroupButtons( inputId = "box2.2_group", - label = "Select group", - choiceNames = c("All", "Year", "Gender", "Department", "Department type", "Specialty", "ICU status", "Clinical status", "Outward status"), + label = trnslt("Select group"), + choiceNames = c(trnslt("All"), trnslt("Year"), trnslt("Gender"), trnslt("Department"), trnslt("Department type"), trnslt("Specialty"), trnslt("ICU status"), trnslt("Clinical status"), trnslt("Outward status")), choiceValues = c("group_all", "year", "gender", "department", "type_dept", "specialism", "is_icu", "is_clinical", "is_outward"), selected = "group_all", direction = "vertical" @@ -325,7 +325,7 @@ server <- function(input, output, session) { ggplot(aes(name, value, fill = name, tooltip = value)) + geom_col_interactive(colour = "black") + scale_fill_manual(values = c("white", "lightgrey", "darkred")) + - labs(x = "", y = "Count", fill = "", title = "Number of positive & negative blood culture tests") + + labs(x = "", y = trnslt("Count"), fill = "", title = trnslt("Number of positive & negative blood culture tests")) + theme_minimal() + theme(text = element_text(family = "Arial"), legend.title = element_blank(), @@ -355,7 +355,12 @@ server <- function(input, output, session) { patho_plot <- reactive({ - mo_search <- c("none", as.mo(input$box2.5_search)) + if (!is.null(input$box2.5_search)) { + mos <- as.mo(input$box2.5_search) + } else { + mos <- character(0) + } + mo_search <- c("none", mos) top_10 <- data_select() %>% filter(!is.na(mo)) %>% @@ -391,7 +396,7 @@ server <- function(input, output, session) { } else { c(0, max(patho_plot %>% count(mo) %>% pull(n))) }) + - labs(x = "", y = "Count", title = "Number of first isolates detected") + + labs(x = "", y = trnslt("Count"), title = trnslt("Number of first isolates detected")) + coord_flip() + theme_minimal() + theme(text = element_text(family = "Arial"), @@ -429,14 +434,17 @@ server <- function(input, output, session) { test_plot <- reactive({ radar_data %>% - mutate(first_14 = first_isolate(radar_data, episode_days = 14, col_patient_id = "patientid"), - first_30 = first_isolate(radar_data, episode_days = 30, col_patient_id = "patientid"), - first_60 = first_isolate(radar_data, episode_days = 60, col_patient_id = "patientid")) %>% + mutate(first_14 = first_isolate(col_mo = "mo", col_date = "date", col_patient_id = "patientid", + episode_days = 14, info = FALSE), + first_30 = first_isolate(col_mo = "mo", col_date = "date", col_patient_id = "patientid", + episode_days = 30, info = FALSE), + first_60 = first_isolate(col_mo = "mo", col_date = "date", col_patient_id = "patientid", + episode_days = 60, info = FALSE)) %>% group_by_at(input$box2.2_group) %>% summarise("14 days" = sum(first_14, na.rm = TRUE), "30 days" = sum(first_30, na.rm = TRUE), - "60 days" = sum(first_60, na.rm = TRUE)) %>% - pivot_longer(cols = c("14 days", "30 days", "60 days")) + "60 days" = sum(first_60, na.rm = TRUE)) + pivot_longer(cols = c("14 days", "30 days", "60 days")) }) @@ -444,7 +452,7 @@ server <- function(input, output, session) { test_plot() %>% ggplot(aes(value, name)) + geom_col(colour = "black", fill = "lightgrey") + - labs(x = "Count", y = "Episode", title = "Number of first isolates per episode") + + labs(x = trnslt("Count"), y = trnslt("Episode"), title = trnslt("Number of first isolates per episode")) + theme_minimal() + theme(text = element_text(family = "Arial"), legend.title = element_blank(), @@ -477,14 +485,14 @@ server <- function(input, output, session) { width = NULL, height = 500, tabPanel( - title = "Resistance profile", + title = trnslt("Resistance profile"), div( style = "position: absolute; left: 0.5em; bottom: 0.5em;", dropdown( radioGroupButtons( inputId = "box1.2_group", - label = "Select group", - choiceNames = c("All", "Year", "Gender", "Department", "Specialty", "Specialty code", "ICU status", "Clinical status", "Outward status"), + label = trnslt("Select group"), + choiceNames = c(trnslt("All"), trnslt("Year"), trnslt("Gender"), trnslt("Department"), trnslt("Specialty"), trnslt("Specialty code"), trnslt("ICU status"), trnslt("Clinical status"), trnslt("Outward status")), choiceValues = c("mo", "year", "gender", "department", "specialty", "specialism", "is_icu", "is_clinical", "is_outward"), selected = "mo", direction = "vertical" @@ -497,7 +505,7 @@ server <- function(input, output, session) { div( style = "position: absolute; right: 3.5em; bottom: 0.5em;", dropdown( - downloadButton(outputId = "down_box_res_prop", label = "Download plot"), + downloadButton(outputId = "down_box_res_prop", label = trnslt("Download plot")), size = "xs", icon = icon("download", class = "opt"), up = TRUE, @@ -525,7 +533,7 @@ server <- function(input, output, session) { ) ), tabPanel( - title = "Combination therapy", + title = trnslt("Combination therapy"), withSpinner( girafeOutput("comb_plot", height = 400), type = 4, @@ -538,11 +546,11 @@ server <- function(input, output, session) { label = "HANDLE WITH CARE", radioGroupButtons( inputId = "comb", - label = HTML("Please read the documentation before interpreting results and modifying underlying algorithm", - as.character(actionLink(inputId = "action_link", label = "(click here)", onclick = 'window.open("https://msberends.github.io/AMR/reference/proportion.html#combination-therapy")'))), + label = HTML(trnslt("Please read the documentation before interpreting results and modifying underlying algorithm"), + as.character(actionLink(inputId = "action_link", label = trnslt("(click here)"), onclick = 'window.open("https://msberends.github.io/AMR/reference/proportion.html#combination-therapy")'))), justified = TRUE, width = 150, - choiceNames = c("Only all tested", "All"), + choiceNames = c(trnslt("Only all tested"), trnslt("All")), choiceValues = c(TRUE, FALSE), size = "xs", direction = "vertical" @@ -555,7 +563,7 @@ server <- function(input, output, session) { div( style = "position: absolute; right: 3.5em; bottom: 0.5em;", dropdown( - downloadButton(outputId = "down_box_comb_prop", label = "Download plot"), + downloadButton(outputId = "down_box_comb_prop", label = trnslt("Download plot")), size = "xs", icon = icon("download", class = "opt"), up = TRUE, @@ -715,7 +723,7 @@ server <- function(input, output, session) { isolate_prop_plot <- reactive({ if (class(try(isolate_prop_data())) == "try-error") { - ggplot(data.frame(), aes(x = 1, y = 1, label = "No tests available")) + + ggplot(data.frame(), aes(x = 1, y = 1, label = trnslt("No tests available"))) + geom_text(size = 5, colour = "red", fontface = "bold", family = "Arial") + theme_void() } else { @@ -974,8 +982,8 @@ server <- function(input, output, session) { list("copy", list( extend = "collection", buttons = c("csv", "excel", "pdf"), - text = "Download")), - lengthMenu = list( c(10, 20, -1), c(10, 20, "All")) , + text = trnslt("Download"))), + lengthMenu = list( c(10, 20, -1), c(10, 20, trnslt("All"))) , pageLength = -1, columnDefs = list(list(className = 'dt-right', targets = "_all")))) } @@ -1075,4 +1083,4 @@ server <- function(input, output, session) { }) -} \ No newline at end of file +} diff --git a/translations.txt b/translations.txt new file mode 100644 index 0000000..1b994ad --- /dev/null +++ b/translations.txt @@ -0,0 +1,45 @@ +en nl +(click here) (klik hier) +14 days 14 dagen +30 days 30 dagen +60 days 60 dagen +About RadaR2 Over RadaR2 +All Alles +All patients Alle patiënten +All specialties selected Alle specialismen +Clinical status Klinische status +Combination therapy Combinatietherapie +Copy Kopiëren +Count Aantal +Define first isolate guidelines Eerste isolaatalgoritme definiëren +Department Afdeling +Department type Afdelingtype +Download Downloaden +Download plot Plot downloaden +Episode Episode +Episode selected Geselecteerde episode +First isolates Eerste isolaten +First isolates per episode Eerste isolaten per episode +Gender Geslacht +ICU status IC-status +No tests available Geen data beschikbaar +Number of first isolates detected Number of first isolates detected +Number of first isolates per episode Number of first isolates per episode +Number of positive & negative blood culture tests Number of positive & negative blood culture tests +Only all tested Alleen alle geteste +Outward status Poli-status +Pathogens Pathogenen +Please read the documentation before interpreting results and modifying underlying algorithm Please read the documentation before interpreting results and modifying underlying algorithm +Positive & negative cultures Positive & negative cultures +Resistance profile Resistantieprofiel +Search and select isolates Isolaten zoeken en selecteren +Search isolates Isolaten zoeken +Select departments Selecteer afdelingen +Select group Groep selecteren +Select pathogen group Pathogeengroep selecteren +Select specialties Selecteer specialisme +Select top ... Top ... selecteren +Specialty Specialisme +Specialty code Specialismecode +Use slider to select by count Use slider to select by count +Year Jaar diff --git a/ui.R b/ui.R index 4689b11..a6a7e20 100644 --- a/ui.R +++ b/ui.R @@ -1,17 +1,17 @@ -ui <- dashboardPagePlus( - title = "RadaR", - skin = "black", collapse_sidebar = TRUE, sidebar_background = "light", +ui <- dashboardPage( + title = "RadaR2", + skin = "black", # HEADER ------------------------------------------------------------------ dashboardHeader( - title = span(img(src = "radar.png", height = 30), strong("RadaR 2.0")), + title = span(img(src = "radar.png", height = 30), strong("RadaR2")), titleWidth = 500, tags$li( a( - strong("About RadaR"), + strong(trnslt("About RadaR2")), height = 40, href = "https://www.jmir.org/2019/6/e12843/", title = "", @@ -28,16 +28,16 @@ ui <- dashboardPagePlus( menuItem(icon = icon("check-square"), materialSwitch( inputId = "allInput", - label = "All specialties selected", + label = trnslt("All specialties selected"), value = TRUE, status = "danger")), menuItem(icon = icon("user-nurse"), checkboxGroupInput(inputId = "specialtyInput", - label = "Select specialties", + label = trnslt("Select specialties"), choices = sort(unique(radar_data$specialty_shiny)))), menuItem(icon = icon("hospital"), checkboxGroupInput(inputId = "departmentInput", - label = "Select departments" , + label = trnslt("Select departments"), choices = sort(unique(radar_data$department)))) ) ),