Dynamically derive supported languages from JSON keys in report language selection
This commit is contained in:
parent
d794f31460
commit
b7757f6a28
|
|
@ -468,7 +468,11 @@ tryCatch({
|
|||
sheet_names <- c("main_translations", "status_translations", "figure_translations")
|
||||
|
||||
# Determine language column (fall back to English)
|
||||
lang_col <- if (language %in% c("en", "es", "pt-br")) language else "en"
|
||||
# Supported languages are derived dynamically from the JSON keys
|
||||
supported_langs <- unique(unlist(lapply(translations_json, function(sheet) {
|
||||
lapply(sheet, names)
|
||||
})))
|
||||
lang_col <- if (language %in% supported_langs) language else "en"
|
||||
if (lang_col != language) {
|
||||
safe_log(paste("Specified language not supported, defaulting to 'en'"), "WARNING")
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -658,11 +658,11 @@ cum_ci_plot <- function(pivotName, ci_quadrant_data = CI_quadrant, plot_type = "
|
|||
plot_data_both <- data_ci3 %>%
|
||||
dplyr::filter(season %in% unique_seasons) %>%
|
||||
dplyr::mutate(
|
||||
ci_type_label = case_when(
|
||||
ci_type_label = factor(case_when(
|
||||
ci_type == "mean_rolling_10_days" ~ rolling_mean_label,
|
||||
ci_type == "cumulative_CI" ~ cumulative_label,
|
||||
TRUE ~ ci_type
|
||||
),
|
||||
), levels = c(rolling_mean_label, cumulative_label)),
|
||||
is_latest = season == latest_season # Flag for latest season
|
||||
)
|
||||
|
||||
|
|
@ -708,11 +708,11 @@ cum_ci_plot <- function(pivotName, ci_quadrant_data = CI_quadrant, plot_type = "
|
|||
} else {
|
||||
DAH
|
||||
},
|
||||
ci_type_label = case_when(
|
||||
ci_type_label = factor(case_when(
|
||||
ci_type == "value" ~ rolling_mean_label,
|
||||
ci_type == "cumulative_CI" ~ cumulative_label,
|
||||
TRUE ~ ci_type
|
||||
)
|
||||
), levels = c(rolling_mean_label, cumulative_label))
|
||||
)
|
||||
ggplot2::geom_smooth(
|
||||
data = benchmark_subset,
|
||||
|
|
|
|||
|
|
@ -437,7 +437,11 @@ tryCatch({
|
|||
sheet_names <- c("main_translations", "status_translations", "figure_translations")
|
||||
|
||||
# Determine language column (fall back to English)
|
||||
lang_col <- if (language %in% c("en", "es-mx", "pt-br", "sw")) language else "en"
|
||||
# Supported languages are derived dynamically from the JSON keys
|
||||
supported_langs <- unique(unlist(lapply(translations_json, function(sheet) {
|
||||
lapply(sheet, names)
|
||||
})))
|
||||
lang_col <- if (language %in% supported_langs) language else "en"
|
||||
if (lang_col != language) {
|
||||
safe_log(paste("Specified language not supported, defaulting to 'en'"), "WARNING")
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue