Skip to content

Commit

Permalink
feat: use pluralize function on other utils.R code
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 15, 2024
1 parent 95593c0 commit 6b2fc08
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,19 @@ check_modules_datanames_html <- function(modules, datanames) {
function(mod) {
tagList(
tags$span(
tags$span(if (length(mod$missing_datanames) == 1) "Dataset" else "Datasets"),
tags$span(pluralize(mod$missing_datanames, "Dataset")),
to_html_code_list(mod$missing_datanames),
tags$span(
paste0(
if (length(mod$missing_datanames) > 1) "are missing" else "is missing",
if (show_module_info) sprintf(" for module '%s'.", mod$label) else "."
sprintf(
"%s missing%s.",
pluralize(mod$missing_datanames, "is", "are"),
if (show_module_info) sprintf(" for module '%s'", mod$label) else ""
)
)
),
if (length(datanames) >= 1) {
tagList(
tags$span(if (length(datanames) == 1) "Dataset" else "Datasets"),
tags$span(pluralize(datanames, "Dataset")),
tags$span("available in data:"),
tagList(
tags$span(
Expand Down Expand Up @@ -408,7 +409,7 @@ paste_datanames_character <- function(x,
tagList(
tags$code(x[.ix]),
if (.ix != length(x)) {
tags$span(ifelse(.ix == length(x) - 1, " and ", ", "))
tags$span(if (.ix == length(x) - 1) " and " else ", ")
}
)
})
Expand All @@ -426,17 +427,18 @@ build_datanames_error_message <- function(label = NULL,
tags = list(span = shiny::tags$span, code = shiny::tags$code),
tagList = shiny::tagList) { # nolint: object_name.
tags$span(
tags$span(ifelse(length(extra_datanames) > 1, "Datasets", "Dataset")),
tags$span(pluralize(extra_datanames, "Dataset")),
paste_datanames_character(extra_datanames, tags, tagList),
tags$span(
paste0(
ifelse(length(extra_datanames) > 1, "are missing", "is missing"),
ifelse(is.null(label), ".", sprintf(" for tab '%s'.", label))
sprintf(
"%s missing%s",
pluralize(extra_datanames, "is", "are"),
if (is.null(label)) "" else sprintf(" for tab '%s'", label)
)
),
if (length(datanames) >= 1) {
tagList(
tags$span(ifelse(length(datanames) > 1, "Datasets", "Dataset")),
tags$span(pluralize(datanames, "Dataset")),
tags$span("available in data:"),
tagList(
tags$span(
Expand Down

0 comments on commit 6b2fc08

Please sign in to comment.