feat: starting to implement translations throughout the UI

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-09-10 12:00:03 +02:00
commit 96e08e44d8
No known key found for this signature in database
42 changed files with 1547 additions and 750 deletions

View file

@ -1 +1 @@
app_version <- function()'25.8.2'
app_version <- function()'25.8.3'

View file

@ -63,7 +63,7 @@ create_column_ui <- function(id) {
width = 6,
textInput(
inputId = ns("new_column"),
label = i18n("New column name:"),
label = i18n$t("New column name:"),
value = "new_column1",
width = "100%"
)
@ -72,7 +72,7 @@ create_column_ui <- function(id) {
width = 6,
shinyWidgets::virtualSelectInput(
inputId = ns("group_by"),
label = i18n("Group calculation by:"),
label = i18n$t("Group calculation by:"),
choices = NULL,
multiple = TRUE,
disableSelectAll = TRUE,
@ -83,7 +83,7 @@ create_column_ui <- function(id) {
),
shiny::textAreaInput(
inputId = ns("expression"),
label = i18n("Enter an expression to define new column:"),
label = i18n$t("Enter an expression to define new column:"),
value = "",
width = "100%",
rows = 6
@ -91,7 +91,7 @@ create_column_ui <- function(id) {
tags$i(
class = "d-block",
phosphoricons::ph("info"),
datamods::i18n("Click on a column name to add it to the expression:")
i18n$t("Click on a column name to add it to the expression:")
),
uiOutput(outputId = ns("columns")),
uiOutput(outputId = ns("feedback")),
@ -105,7 +105,7 @@ create_column_ui <- function(id) {
actionButton(
inputId = ns("compute"),
label = tagList(
phosphoricons::ph("gear"), i18n("Create column")
phosphoricons::ph("gear"), i18n$t("Create column")
),
class = "btn-outline-primary",
width = "100%"
@ -140,9 +140,9 @@ create_column_server <- function(id,
info_alert <- shinyWidgets::alert(
status = "info",
phosphoricons::ph("question"),
datamods::i18n("Choose a name for the column to be created or modified,"),
datamods::i18n("then enter an expression before clicking on the button above to validate or on "),
phosphoricons::ph("trash"), datamods::i18n("to delete it.")
i18n$t("Choose a name for the column to be created or modified,"),
i18n$t("then enter an expression before clicking on the button above to validate or on "),
phosphoricons::ph("trash"), i18n$t("to delete it.")
)
rv <- reactiveValues(
@ -187,7 +187,7 @@ create_column_server <- function(id,
if (input$new_column == "") {
rv$feedback <- shinyWidgets::alert(
status = "warning",
phosphoricons::ph("warning"), datamods::i18n("New column name cannot be empty")
phosphoricons::ph("warning"), i18n$t("New column name cannot be empty")
)
}
})
@ -252,7 +252,7 @@ list_allowed_operations <- function() {
#'
#' @rdname create-column
modal_create_column <- function(id,
title = i18n("Create a new column"),
title = i18n$t("Create a new column"),
easyClose = TRUE,
size = "l",
footer = NULL) {
@ -277,7 +277,7 @@ modal_create_column <- function(id,
#' @importFrom htmltools tagList
#' @rdname create-column
winbox_create_column <- function(id,
title = i18n("Create a new column"),
title = i18n$t("Create a new column"),
options = shinyWidgets::wbOptions(),
controls = shinyWidgets::wbControls()) {
ns <- NS(id)
@ -311,7 +311,7 @@ try_compute_column <- function(expression,
}
funs <- unlist(c(extract_calls(parsed), lapply(parsed, extract_calls)), recursive = TRUE)
if (!are_allowed_operations(funs, allowed_operations)) {
return(datamods:::alert_error(datamods::i18n("Some operations are not allowed")))
return(datamods:::alert_error(i18n$t("Some operations are not allowed")))
}
if (!isTruthy(by)) {
result <- try(
@ -351,7 +351,7 @@ try_compute_column <- function(expression,
)
shinyWidgets::alert(
status = "success",
phosphoricons::ph("check"), datamods::i18n("Column added!")
phosphoricons::ph("check"), i18n$t("Column added!")
)
}
@ -421,7 +421,7 @@ make_choices_with_infos <- function(data) {
# NULL
# }
description <- if (is.atomic(values)) {
paste(i18n("Unique values:"), data.table::uniqueN(values))
paste(i18n$t("Unique values:"), data.table::uniqueN(values))
} else {
""
}

View file

@ -208,7 +208,7 @@ cut_variable_ui <- function(id) {
width = 3,
shinyWidgets::virtualSelectInput(
inputId = ns("variable"),
label = datamods:::i18n("Variable to cut:"),
label = i18n$t("Variable to cut:"),
choices = NULL,
width = "100%"
)
@ -221,7 +221,7 @@ cut_variable_ui <- function(id) {
width = 3,
numericInput(
inputId = ns("n_breaks"),
label = datamods:::i18n("Number of breaks:"),
label = i18n$t("Number of breaks:"),
value = 3,
min = 2,
max = 12,
@ -232,12 +232,12 @@ cut_variable_ui <- function(id) {
width = 3,
checkboxInput(
inputId = ns("right"),
label = datamods:::i18n("Close intervals on the right"),
label = i18n$t("Close intervals on the right"),
value = TRUE
),
checkboxInput(
inputId = ns("include_lowest"),
label = datamods:::i18n("Include lowest value"),
label = i18n$t("Include lowest value"),
value = TRUE
)
)
@ -251,7 +251,7 @@ cut_variable_ui <- function(id) {
toastui::datagridOutput2(outputId = ns("count")),
actionButton(
inputId = ns("create"),
label = tagList(phosphoricons::ph("scissors"), datamods:::i18n("Create factor variable")),
label = tagList(phosphoricons::ph("scissors"), i18n$t("Create factor variable")),
class = "btn-outline-primary float-end"
),
tags$div(class = "clearfix")
@ -321,7 +321,7 @@ cut_variable_server <- function(id, data_r = reactive(NULL)) {
shinyWidgets::noUiSliderInput(
inputId = session$ns("fixed_brks"),
label = datamods:::i18n("Fixed breaks:"),
label = i18n$t("Fixed breaks:"),
min = lower,
max = upper,
value = brks,
@ -376,7 +376,7 @@ cut_variable_server <- function(id, data_r = reactive(NULL)) {
shinyWidgets::virtualSelectInput(
inputId = session$ns("method"),
label = datamods:::i18n("Method:"),
label = i18n$t("Method:"),
choices = choices,
selected = NULL,
width = "100%"
@ -570,7 +570,7 @@ cut_variable_server <- function(id, data_r = reactive(NULL)) {
#'
#' @rdname cut-variable
modal_cut_variable <- function(id,
title = datamods:::i18n("Convert Numeric to Factor"),
title = i18n$t("Convert Numeric to Factor"),
easyClose = TRUE,
size = "l",
footer = NULL) {

View file

@ -129,14 +129,14 @@ describe_col_char <- function(x, with_summary = TRUE) {
tagList(
tags$hr(style = htmltools::css(margin = "3px 0")),
tags$div(
datamods:::i18n("Unique:"), length(unique(x))
i18n$t("Unique:"), length(unique(x))
),
tags$div(
datamods:::i18n("Missing:"), sum(is.na(x))
i18n$t("Missing:"), sum(is.na(x))
),
tags$div(
style = htmltools::css(whiteSpace = "normal", wordBreak = "break-all"),
datamods:::i18n("Most Common:"), gsub(
i18n$t("Most Common:"), gsub(
pattern = "'",
replacement = "\u07F4",
x = names(sort(table(x), decreasing = TRUE))[1]
@ -178,7 +178,7 @@ describe_col_factor <- function(x, with_summary = TRUE) {
names(two), ":", fmt_p(two, total)
),
tags$div(
"Missing", ":", fmt_p(missing, total)
i18n$t("Missing:"), fmt_p(missing, total)
),
tags$div(
"\u00A0"
@ -201,16 +201,16 @@ describe_col_num <- function(x, with_summary = TRUE) {
tagList(
tags$hr(style = htmltools::css(margin = "3px 0")),
tags$div(
datamods:::i18n("Min:"), round(min(x, na.rm = TRUE), 2)
i18n$t("Min:"), round(min(x, na.rm = TRUE), 2)
),
tags$div(
datamods:::i18n("Mean:"), round(mean(x, na.rm = TRUE), 2)
i18n$t("Mean:"), round(mean(x, na.rm = TRUE), 2)
),
tags$div(
datamods:::i18n("Max:"), round(max(x, na.rm = TRUE), 2)
i18n$t("Max:"), round(max(x, na.rm = TRUE), 2)
),
tags$div(
datamods:::i18n("Missing:"), sum(is.na(x))
i18n$t("Missing:"), sum(is.na(x))
)
)
}
@ -231,13 +231,13 @@ describe_col_date <- function(x, with_summary = TRUE) {
tagList(
tags$hr(style = htmltools::css(margin = "3px 0")),
tags$div(
datamods:::i18n("Min:"), min(x, na.rm = TRUE)
i18n$t("Min:"), min(x, na.rm = TRUE)
),
tags$div(
datamods:::i18n("Max:"), max(x, na.rm = TRUE)
i18n$t("Max:"), max(x, na.rm = TRUE)
),
tags$div(
datamods:::i18n("Missing:"), sum(is.na(x))
i18n$t("Missing:"), sum(is.na(x))
),
tags$div(
"\u00A0"
@ -260,13 +260,13 @@ describe_col_datetime <- function(x, with_summary = TRUE) {
tagList(
tags$hr(style = htmltools::css(margin = "3px 0")),
tags$div(
datamods:::i18n("Min:"), min(x, na.rm = TRUE)
i18n$t("Min:"), min(x, na.rm = TRUE)
),
tags$div(
datamods:::i18n("Max:"), max(x, na.rm = TRUE)
i18n$t("Max:"), max(x, na.rm = TRUE)
),
tags$div(
datamods:::i18n("Missing:"), sum(is.na(x))
i18n$t("Missing:"), sum(is.na(x))
),
tags$div(
"\u00A0"
@ -290,10 +290,10 @@ describe_col_other <- function(x, with_summary = TRUE) {
tagList(
tags$hr(style = htmltools::css(margin = "3px 0")),
tags$div(
datamods:::i18n("Unique:"), length(unique(x))
i18n$t("Unique:"), length(unique(x))
),
tags$div(
datamods:::i18n("Missing:"), sum(is.na(x))
i18n$t("Missing:"), sum(is.na(x))
),
tags$div(
"\u00A0"

View file

@ -1 +1 @@
hosted_version <- function()'v25.8.2-250827'
hosted_version <- function()'v25.8.3-250910'

View file

@ -24,7 +24,7 @@ import_file_ui <- function(id,
if (isTRUE(title)) {
title <- shiny::tags$h4(
datamods:::i18n("Import a file"),
"Import a file",
class = "datamods-title"
)
}
@ -35,7 +35,7 @@ import_file_ui <- function(id,
width = 6,
shinyWidgets::numericInputIcon(
inputId = ns("skip_rows"),
label = datamods:::i18n("Rows to skip before reading data:"),
label = i18n$t("Rows to skip before reading data:"),
value = 0,
min = 0,
icon = list("n ="),
@ -45,20 +45,20 @@ import_file_ui <- function(id,
shiny::tagAppendChild(
shinyWidgets::textInputIcon(
inputId = ns("na_label"),
label = datamods:::i18n("Missing values character(s):"),
label = i18n$t("Missing values character(s):"),
value = "NA,,'',na",
icon = list("NA"),
size = "sm",
width = "100%"
),
shiny::helpText(phosphoricons::ph("info"), datamods:::i18n("if several use a comma (',') to separate them"))
shiny::helpText(phosphoricons::ph("info"), i18n$t("if several use a comma (',') to separate them"))
)
),
shiny::column(
width = 6,
shinyWidgets::textInputIcon(
inputId = ns("dec"),
label = datamods:::i18n("Decimal separator:"),
label = i18n$t("Decimal separator:"),
value = ".",
icon = list("0.00"),
size = "sm",
@ -66,7 +66,7 @@ import_file_ui <- function(id,
),
selectInputIcon(
inputId = ns("encoding"),
label = datamods:::i18n("Encoding:"),
label = i18n$t("Encoding:"),
choices = c(
"UTF-8" = "UTF-8",
"Latin1" = "latin1"
@ -81,9 +81,9 @@ import_file_ui <- function(id,
file_ui <- shiny::tagAppendAttributes(
shiny::fileInput(
inputId = ns("file"),
label = datamods:::i18n("Upload a file:"),
buttonLabel = datamods:::i18n("Browse..."),
placeholder = datamods:::i18n("No file selected; maximum file size is 5 mb"),
label = i18n$t("Upload a file:"),
buttonLabel = i18n$t("Browse..."),
placeholder = "No file selected; maximum file size is 5 mb",
accept = file_extensions,
width = "100%",
## A solution to allow multiple file upload is being considered
@ -130,7 +130,7 @@ import_file_ui <- function(id,
id = ns("sheet-container"),
shinyWidgets::pickerInput(
inputId = ns("sheet"),
label = datamods:::i18n("Select sheet to import:"),
label = i18n$t("Select sheet to import:"),
choices = NULL,
width = "100%",
multiple = TRUE
@ -141,8 +141,11 @@ import_file_ui <- function(id,
shinyWidgets::alert(
id = ns("import-result"),
status = "info",
shiny::tags$b(datamods:::i18n("No file selected:")),
sprintf(datamods:::i18n("You can import %s files"), paste(file_extensions, collapse = ", ")),
shiny::tags$b(i18n$t("No file selected.")),
# shiny::textOutput(ns("trans_format_text")),
# This is the easiest solution, though not gramatically perfect
i18n$t("You can choose between these file types:"), paste(file_extensions,collapse=', '),
# sprintf("You can import %s files", paste(file_extensions, collapse = ", ")),
dismissible = TRUE
)
),
@ -173,6 +176,7 @@ import_file_server <- function(id,
btn_show_data = TRUE,
show_data_in = c("popup", "modal"),
trigger_return = c("button", "change"),
file_extensions_text = paste(c(".csv", ".txt", ".xls", ".xlsx", ".rds", ".fst", ".sas7bdat", ".sav"),collapse = ", "),
return_class = c("data.frame", "data.table", "tbl_df", "raw"),
reset = reactive(NULL)) {
read_fns <- list(
@ -206,6 +210,11 @@ import_file_server <- function(id,
}
})
# ## Translations
# shiny::observe({
# output$trans_format_text <- shiny::renderText(glue::glue(i18n$t("You can import {file_extensions_text} files")))
# })
shiny::observeEvent(input$file, {
## Several steps are taken to ensure no errors on changed input file
temporary_rv$sheets <- 1
@ -270,7 +279,7 @@ import_file_server <- function(id,
if (inherits(imported, "try-error") || NROW(imported) < 1) {
datamods:::toggle_widget(inputId = "confirm", enable = FALSE)
datamods:::insert_error(mssg = datamods:::i18n(attr(imported, "condition")$message))
datamods:::insert_error(mssg = i18n$t(attr(imported, "condition")$message))
temporary_rv$status <- "error"
temporary_rv$data <- NULL
temporary_rv$name <- NULL
@ -285,7 +294,7 @@ import_file_server <- function(id,
imported,
trigger_return = trigger_return,
btn_show_data = btn_show_data,
extra = if (isTRUE(input$preview_data)) datamods:::i18n("First five rows are shown below:")
extra = if (isTRUE(input$preview_data)) i18n$t("First five rows are shown below:")
)
)
temporary_rv$status <- "success"
@ -300,7 +309,7 @@ import_file_server <- function(id,
observeEvent(input$see_data, {
tryCatch(
{
datamods:::show_data(default_parsing(temporary_rv$data), title = datamods:::i18n("Imported data"), type = show_data_in)
datamods:::show_data(default_parsing(temporary_rv$data), title = i18n$t("Imported data"), type = show_data_in)
},
# warning = function(warn) {
# showNotification(warn, type = "warning")

Binary file not shown.

8
R/translate.R Normal file
View file

@ -0,0 +1,8 @@
language_choices <- function() {
c(
"🇬🇧 English" = "en",
"🇹🇿 Kiswahili" = "sw",
"🇩🇰 Dansk" = "da"
)
}

View file

@ -17,6 +17,10 @@ ui_elements <- function(selection) {
# title = shiny::div(htmltools::img(src="FreesearchR-logo-white-nobg-h80.png")),
icon = shiny::icon("house"),
shiny::fluidRow(
# "The browser language is",
# textOutput("your_lang"),
# p(i18n$t("Hello")),
# shiny::uiOutput(outputId = "language_select"),
## On building the dev-version for shinyapps.io, the dev_banner() is redefined
## Default just output "NULL"
## This could probably be achieved more legantly, but this works.
@ -24,9 +28,12 @@ ui_elements <- function(selection) {
shiny::column(width = 2),
shiny::column(
width = 8,
shiny::markdown(readLines("www/intro.md")),
shiny::column(width = 2)
)
shiny::uiOutput(outputId = "language_select"),
htmlOutput("intro_text")
# shiny::includeHTML(i18n$t("www/intro.html"))
# shiny::markdown(readLines(i18n$t("www/intro.md")))
),
shiny::column(width = 2)
)
),
##############################################################################
@ -35,28 +42,32 @@ ui_elements <- function(selection) {
#########
##############################################################################
"import" = bslib::nav_panel(
title = "Get started",
title = i18n$t("Get started"),
icon = shiny::icon("play"),
value = "nav_import",
shiny::fluidRow(
shiny::column(width = 2),
shiny::column(
width = 8,
shiny::h4("Choose your data source"),
shiny::br(),
shiny::h4(i18n$t("Choose your data")),
# shiny::br(),
# shiny::uiOutput(outputId = "source"),
shinyWidgets::radioGroupButtons(
# radioGroupButtons(
# inputId = "source",
# selected = "file",
# choices = c("File" = "file"),
# size = "lg"
# ),
shiny::selectInput(
inputId = "source",
label="",
selected = "file",
choices = c(
"File upload" = "file",
"REDCap server export" = "redcap",
"Local or sample data" = "env"
),
size = "lg"
choices = "file",
width = "100%"
),
shiny::tags$script('document.querySelector("#source div").style.width = "100%"'),
shiny::helpText("Upload a file from your device, get data directly from REDCap or select a sample data set for testing from the app."),
# shiny::tags$script('document.querySelector("#source div").style.width = "100%"'),
## Update this to change depending on run locally or hosted
shiny::helpText(i18n$t("Upload a file, get data directly from REDCap or use local or sample data.")),
shiny::br(),
shiny::br(),
shiny::conditionalPanel(
@ -70,13 +81,14 @@ ui_elements <- function(selection) {
),
shiny::conditionalPanel(
condition = "input.source=='redcap'",
shinyWidgets::alert(
id = "redcap-warning",
status = "info",
shiny::tags$h2(shiny::markdown("Careful with sensitive data")),
shiny::tags$p("The", shiny::tags$i(shiny::tags$b("FreesearchR")), "app only stores data for analyses, but please only use with sensitive data when running locally.", "", shiny::tags$a("Read more here", href = "https://agdamsbo.github.io/FreesearchR/#run-locally-on-your-own-machine"), "."),
dismissible = TRUE
),
shiny::uiOutput(outputId = "redcap_warning"),
# shinyWidgets::alert(
# id = "redcap-warning",
# status = "warning",
# shiny::tags$h2(i18n$t("Please be mindfull handling sensitive data")),
# shiny::HTML(i18n$t("<p>The <em><strong>FreesearchR</strong></em> app only stores data for analyses, but please only use with sensitive data when running locally. <a href='https://agdamsbo.github.io/FreesearchR/#run-locally-on-your-own-machine'>Read more here</a></p>")),
# dismissible = TRUE
# ),
m_redcap_readUI(
id = "redcap_import",
title = ""
@ -95,18 +107,18 @@ ui_elements <- function(selection) {
shiny::br(),
shiny::actionButton(
inputId = "modal_initial_view",
label = "Quick overview",
label = i18n$t("Quick overview"),
width = "100%",
icon = shiny::icon("binoculars"),
disabled = FALSE
),
shiny::br(),
shiny::br(),
shiny::h5("Select variables for final import"),
shiny::h5(i18n$t("Select variables for final import")),
shiny::fluidRow(
shiny::column(
width = 6,
shiny::p("Exclude incomplete variables:"),
shiny::p(i18n$t("Exclude incomplete variables:")),
shiny::br(),
shinyWidgets::noUiSliderInput(
inputId = "complete_cutoff",
@ -119,12 +131,12 @@ ui_elements <- function(selection) {
format = shinyWidgets::wNumbFormat(decimals = 0),
color = datamods:::get_primary_color()
),
shiny::helpText("Only include variables missing less observations than the specified percentage."),
shiny::helpText(i18n$t("Only include variables missing less observations than the specified percentage. At 0, only complete variables are included; at 100, all variables are included.")),
shiny::br()
),
shiny::column(
width = 6,
shiny::p("Manual selection:"),
shiny::p(i18n$t("Manual selection:")),
shiny::br(),
shiny::uiOutput(outputId = "import_var"),
shiny::br()
@ -135,12 +147,11 @@ ui_elements <- function(selection) {
shiny::br(),
shiny::actionButton(
inputId = "act_start",
label = "Start",
label = i18n$t("Let's begin!"),
width = "100%",
icon = shiny::icon("play"),
disabled = TRUE
),
shiny::helpText('After importing, hit "Start" or navigate to the desired tab.'),
shiny::br(),
shiny::br()
),
@ -160,24 +171,23 @@ ui_elements <- function(selection) {
icon = shiny::icon("pen-to-square"),
value = "nav_prepare",
bslib::nav_panel(
title = "Overview and filter",
title = i18n$t("Overview and filter"),
icon = shiny::icon("eye"),
value = "nav_prepare_overview",
tags$h3("Overview and filtering"),
# validation_ui("validation_col"),
tags$h3(i18n$t("Overview and filtering")),
fluidRow(
shiny::column(
width = 9,
shiny::uiOutput(outputId = "data_info", inline = TRUE),
shiny::tags$p(
"Below is a short summary table, on the right you can click to visualise data classes or browse data and create different data filters."
i18n$t("Below you find a summary table for quick insigths, and on the right you can visualise data classes, browse data and apply different data filters.")
)
),
shiny::column(
width = 3,
shiny::actionButton(
inputId = "modal_visual_overview",
label = "Visual overview",
label = i18n$t("Visual overview"),
width = "100%",
disabled = TRUE
),
@ -185,7 +195,7 @@ ui_elements <- function(selection) {
shiny::br(),
shiny::actionButton(
inputId = "modal_browse",
label = "Browse data",
label = i18n$t("Browse data"),
width = "100%",
disabled = TRUE
),
@ -205,21 +215,24 @@ ui_elements <- function(selection) {
),
shiny::column(
width = 3,
shiny::tags$h6("Filter data types"),
shiny::tags$h6(i18n$t("Filter data types")),
shiny::uiOutput(
outputId = "column_filter"
),
## This needs to run in server for translation
shiny::helpText("Read more on how ", tags$a(
"data types",
href = "https://agdamsbo.github.io/FreesearchR/articles/data-types.html",
target = "_blank",
rel = "noopener noreferrer"
), " are defined."),
validation_ui("validation_var"),
shiny::br(),
shiny::br(),
shiny::tags$h6("Filter observations"),
shiny::tags$p("Filter on observation level"),
shiny::tags$h6(i18n$t("Filter observations")),
shiny::tags$p(i18n$t("Apply filter on observation")),
IDEAFilter::IDEAFilter_ui("data_filter"),
validation_ui("validation_obs"),
shiny::br(),
shiny::br()
)
@ -229,24 +242,24 @@ ui_elements <- function(selection) {
shiny::br()
),
bslib::nav_panel(
title = "Modify",
title = i18n$t("Edit and create data"),
icon = shiny::icon("file-pen"),
tags$h3("Subset, rename and convert variables"),
tags$h3(i18n$t("Subset, rename and convert variables")),
fluidRow(
shiny::column(
width = 9,
shiny::tags$p(
shiny::markdown("Below, are several options for simple data manipulation like update variables by renaming, creating new labels (for nicer tables in the report) and changing variable classes (numeric, factor/categorical etc.)."),
shiny::markdown("There are more advanced options to modify factor/categorical variables as well as create new factor from a continous variable or new variables with *R* code. At the bottom you can restore the original data."),
shiny::markdown("Please note that data modifications are applied before any filtering.")
i18n$t("Below, are several options for simple data manipulation like update variables by renaming, creating new labels (for nicer tables in the report) and changing variable classes (numeric, factor/categorical etc.)."),
i18n$t("There are more advanced options to modify factor/categorical variables as well as create new factor from a continous variable or new variables with R code. At the bottom you can restore the original data."),
i18n$t("Please note that data modifications are applied before any filtering.")
)
)
),
update_variables_ui("modal_variables"),
shiny::tags$br(),
shiny::tags$br(),
shiny::tags$h4("Advanced data manipulation"),
shiny::tags$p("Below options allow more advanced varaible manipulations."),
shiny::tags$h4(i18n$t("Advanced data manipulation")),
shiny::tags$p(i18n$t("Below options allow more advanced varaible manipulations.")),
shiny::tags$br(),
shiny::tags$br(),
shiny::fluidRow(
@ -254,11 +267,11 @@ ui_elements <- function(selection) {
width = 4,
shiny::actionButton(
inputId = "modal_update",
label = "Reorder factor levels",
label = i18n$t("Reorder factor levels"),
width = "100%"
),
shiny::tags$br(),
shiny::helpText("Reorder the levels of factor/categorical variables."),
shiny::helpText(i18n$t("Reorder the levels of factor/categorical variables.")),
shiny::tags$br(),
shiny::tags$br()
),
@ -266,11 +279,11 @@ ui_elements <- function(selection) {
width = 4,
shiny::actionButton(
inputId = "modal_cut",
label = "New factor",
label = i18n$t("New factor"),
width = "100%"
),
shiny::tags$br(),
shiny::helpText("Create factor/categorical variable from a continous variable (number/date/time)."),
shiny::helpText(i18n$t("Create factor/categorical variable from a continous variable (number/date/time).")),
shiny::tags$br(),
shiny::tags$br()
),
@ -278,30 +291,30 @@ ui_elements <- function(selection) {
width = 4,
shiny::actionButton(
inputId = "modal_column",
label = "New variable",
label = i18n$t("New variable"),
width = "100%"
),
shiny::tags$br(),
shiny::helpText(shiny::markdown("Create a new variable/column based on an *R*-expression.")),
shiny::helpText(i18n$t("Create a new variable based on an R-expression.")),
shiny::tags$br(),
shiny::tags$br()
)
),
tags$h4("Compare modified data to original"),
tags$h4(i18n$t("Compare modified data to original")),
shiny::tags$br(),
shiny::tags$p(
"Raw print of the original vs the modified data."
i18n$t("Raw print of the original vs the modified data.")
),
shiny::tags$br(),
shiny::fluidRow(
shiny::column(
width = 6,
shiny::tags$b("Original data:"),
shiny::tags$b(i18n$t("Original data:")),
shiny::verbatimTextOutput("original_str")
),
shiny::column(
width = 6,
shiny::tags$b("Modified data:"),
shiny::tags$b(i18n$t("Modified data:")),
shiny::verbatimTextOutput("modified_str")
)
),
@ -431,7 +444,7 @@ ui_elements <- function(selection) {
),
##############################################################################
#########
######### Download panel
######### Visuals panel
#########
##############################################################################
"visuals" = do.call(
@ -481,11 +494,13 @@ ui_elements <- function(selection) {
shiny::column(width = 2),
shiny::column(
width = 8,
shiny::h4(i18n$t("Analysis validation")),
validation_ui("validation_all"),
shiny::fluidRow(
shiny::column(
width = 6,
shiny::h4("Report"),
shiny::helpText("Choose your favourite output file format for further work, and download, when the analyses are done."),
shiny::h4(i18n$t("Report")),
shiny::helpText(i18n$t("Choose your favourite output file format for further work, and download, when the analyses are done.")),
shiny::br(),
shiny::br(),
shiny::selectInput(
@ -590,13 +605,12 @@ ui_elements <- function(selection) {
# shiny::br()
# )
)
if (!is.null(selection)){
out[[selection]]
} else {
out
}
if (!is.null(selection)) {
out[[selection]]
} else {
out
}
}
# ls <- list("home"=1:4,

View file

@ -33,7 +33,7 @@ update_factor_ui <- function(id) {
width = 6,
shinyWidgets::virtualSelectInput(
inputId = ns("variable"),
label = i18n("Factor variable to reorder:"),
label = i18n$t("Factor variable to reorder:"),
choices = NULL,
width = "100%",
zIndex = 50
@ -46,7 +46,7 @@ update_factor_ui <- function(id) {
inputId = ns("sort_levels"),
label = tagList(
phosphoricons::ph("sort-ascending"),
datamods:::i18n("Sort by levels")
i18n$t("Sort by levels")
),
class = "btn-outline-primary mb-3",
width = "100%"
@ -59,7 +59,7 @@ update_factor_ui <- function(id) {
inputId = ns("sort_occurrences"),
label = tagList(
phosphoricons::ph("sort-ascending"),
datamods:::i18n("Sort by count")
i18n$t("Sort by count")
),
class = "btn-outline-primary mb-3",
width = "100%"
@ -71,7 +71,7 @@ update_factor_ui <- function(id) {
class = "float-end",
shinyWidgets::prettyCheckbox(
inputId = ns("new_var"),
label = datamods:::i18n("Create a new variable (otherwise replaces the one selected)"),
label = i18n$t("Create a new variable (otherwise replaces the one selected)"),
value = FALSE,
status = "primary",
outline = TRUE,
@ -79,7 +79,7 @@ update_factor_ui <- function(id) {
),
actionButton(
inputId = ns("create"),
label = tagList(phosphoricons::ph("arrow-clockwise"), datamods:::i18n("Update factor variable")),
label = tagList(phosphoricons::ph("arrow-clockwise"), i18n$t("Update factor variable")),
class = "btn-outline-primary"
)
),
@ -146,13 +146,13 @@ update_factor_server <- function(id, data_r = reactive(NULL)) {
decreasing <- FALSE
label <- tagList(
phosphoricons::ph("sort-descending"),
datamods:::i18n("Sort count")
i18n$t("Sort count")
)
} else {
decreasing <- TRUE
label <- tagList(
phosphoricons::ph("sort-ascending"),
datamods:::i18n("Sort count")
i18n$t("Sort count")
)
}
updateActionButton(inputId = "sort_occurrences", label = as.character(label))
@ -179,7 +179,7 @@ update_factor_server <- function(id, data_r = reactive(NULL)) {
grid <- grid_columns(
grid,
columns = c("Var1", "Var1_toset", "Freq"),
header = c(datamods:::i18n("Levels"), "New label", datamods:::i18n("Count"))
header = c(i18n$t("Levels"), "New label", i18n$t("Count"))
)
grid <- grid_colorbar(
grid,
@ -241,7 +241,7 @@ update_factor_server <- function(id, data_r = reactive(NULL)) {
#'
#' @rdname update-factor
modal_update_factor <- function(id,
title = i18n("Update levels of a factor"),
title = i18n$t("Update levels of a factor"),
easyClose = TRUE,
size = "l",
footer = NULL) {
@ -267,7 +267,7 @@ modal_update_factor <- function(id,
#' @importFrom htmltools tagList
#' @rdname update-factor
winbox_update_factor <- function(id,
title = i18n("Update levels of a factor"),
title = i18n$t("Update levels of a factor"),
options = shinyWidgets::wbOptions(),
controls = shinyWidgets::wbControls()) {
ns <- NS(id)

View file

@ -13,7 +13,7 @@ update_variables_ui <- function(id, title = "") {
ns <- NS(id)
if (isTRUE(title)) {
title <- htmltools::tags$h4(
i18n("Update & select variables"),
i18n$t("Update & select variables"),
class = "datamods-title"
)
}
@ -35,19 +35,19 @@ update_variables_ui <- function(id, title = "") {
),
shinyWidgets::textInputIcon(
inputId = ns("format"),
label = i18n("Date format:"),
label = i18n$t("Date format:"),
value = "%Y-%m-%d",
icon = list(phosphoricons::ph("clock"))
),
shinyWidgets::textInputIcon(
inputId = ns("origin"),
label = i18n("Date to use as origin to convert date/datetime:"),
label = i18n$t("Date to use as origin to convert date/datetime:"),
value = "1970-01-01",
icon = list(phosphoricons::ph("calendar"))
),
shinyWidgets::textInputIcon(
inputId = ns("dec"),
label = i18n("Decimal separator:"),
label = i18n$t("Decimal separator:"),
value = ".",
icon = list("0.00")
)
@ -75,8 +75,8 @@ update_variables_ui <- function(id, title = "") {
shiny::actionButton(
inputId = ns("validate"),
label = htmltools::tagList(
phosphoricons::ph("arrow-circle-right", title = datamods::i18n("Apply changes")),
datamods::i18n("Apply changes")
phosphoricons::ph("arrow-circle-right", title = i18n$t("Apply changes")),
i18n$t("Apply changes")
),
width = "100%"
)
@ -115,12 +115,12 @@ update_variables_server <- function(id,
output$data_info <- shiny::renderUI({
shiny::req(data_r())
data_description(data_r())
# sprintf(i18n("Data has %s observations and %s variables."), nrow(data), ncol(data))
# sprintf(i18n$t("Data has %s observations and %s variables."), nrow(data), ncol(data))
})
variables_r <- shiny::reactive({
shiny::validate(
shiny::need(data(), i18n("No data to display."))
shiny::need(data(), i18n$t("No data to display."))
)
data <- data_r()
if (isTRUE(return_data_on_init)) {
@ -225,7 +225,7 @@ update_variables_server <- function(id,
datamods:::insert_alert(
selector = ns("update"),
status = "success",
tags$b(phosphoricons::ph("check"), datamods::i18n("Data successfully updated!"))
tags$b(phosphoricons::ph("check"), i18n$t("Data successfully updated!"))
)
updated_data$x <- data
updated_data$list_rename <- list_rename
@ -804,3 +804,4 @@ clean_date <- function(data) {
}) |>
unname()
}
#