From cd1b5664450c3cd537d9e8ac246c8ab448ab0f8c Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Thu, 21 Nov 2024 09:46:50 +0000 Subject: [PATCH] Translate the error messages --- NEWS.md | 2 +- R/model.R | 6 ++---- inst/traduire/en-translation.json | 3 ++- inst/traduire/fr-translation.json | 3 ++- inst/traduire/pt-translation.json | 3 ++- tests/testthat/test-04-model-frame.R | 10 +++++----- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1ccaa0cd..3501a9d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # naomi 2.10.2 -* Improve warning generated when user fits model at admin level where no population data exists. +* Improve error generated when user fits model at admin level where no population data exists. # naomi 2.10.1 diff --git a/R/model.R b/R/model.R index 85a6da85..7476025c 100644 --- a/R/model.R +++ b/R/model.R @@ -329,10 +329,8 @@ naomi_model_frame <- function(area_merged, ## of a Spectrum file and then calibrated. Currently no way to know if areas ## comparise only part of a Spectrum file, so can't address. - if(any( mf_areas[["area_id"]] %in% unique(population_agesex$area_id) == FALSE)){ - stop( - "Population data not available for admin level selected for model projections. - Please review model options selection to ensure that area level selection is correct.") + if (!all(mf_areas[["area_id"]] %in% unique(population_agesex$area_id))) { + stop(t_("MISSING_POPULATION_LEVEL")) } pop_subset <- dplyr::filter(population_agesex, area_id %in% mf_areas[["area_id"]]) diff --git a/inst/traduire/en-translation.json b/inst/traduire/en-translation.json index 4b66a289..5544b96c 100644 --- a/inst/traduire/en-translation.json +++ b/inst/traduire/en-translation.json @@ -275,5 +275,6 @@ "DOWNLOAD_COMPARISON_DESCRIPTION": "Naomi comparison report uploaded from Naomi web app", "DOWNLOAD_AGYW_DESCRIPTION": "Naomi AGYW tool uploaded from Naomi web app", "NUMBER_ON_ART": "Number on ART", - "NUMBER_ON_ART_DESC": "Number on ART description" + "NUMBER_ON_ART_DESC": "Number on ART description", + "MISSING_POPULATION_LEVEL": "Population data not available for admin level selected for model projections. Please review model options selection to ensure that area level selection is correct." } diff --git a/inst/traduire/fr-translation.json b/inst/traduire/fr-translation.json index 845a1539..1f307723 100644 --- a/inst/traduire/fr-translation.json +++ b/inst/traduire/fr-translation.json @@ -274,5 +274,6 @@ "DOWNLOAD_SUMMARY_DESCRIPTION": "Rapport de synthèse Naomi téléchargé depuis l'application web Naomi", "DOWNLOAD_COMPARISON_DESCRIPTION": "Rapport de comparaison Naomi téléchargé à partir de l'application web Naomi", "NUMBER_ON_ART": "Nombre de personnes sous TARV", - "NUMBER_ON_ART_DESC": "Number on ART description" + "NUMBER_ON_ART_DESC": "Number on ART description", + "MISSING_POPULATION_LEVEL": "Les données de population ne sont pas disponibles pour le niveau admin sélectionné pour les projections du modèle. Veuillez revoir la sélection des options du modèle pour vous assurer que la sélection du niveau de la zone est correcte." } diff --git a/inst/traduire/pt-translation.json b/inst/traduire/pt-translation.json index add5e8a0..a6f7768c 100644 --- a/inst/traduire/pt-translation.json +++ b/inst/traduire/pt-translation.json @@ -274,5 +274,6 @@ "DOWNLOAD_SUMMARY_DESCRIPTION": "Relatório de síntese da Naomi carregado da aplicação web Naomi", "DOWNLOAD_COMPARISON_DESCRIPTION": "Relatório de comparação Naomi carregado a partir da aplicação web Naomi", "NUMBER_ON_ART": "Nombre de personnes sous TARV", - "NUMBER_ON_ART_DESC": "Number on ART description" + "NUMBER_ON_ART_DESC": "Number on ART description", + "MISSING_POPULATION_LEVEL": "Os dados da população não estão disponíveis para o nível administrativo selecionado para as projecções do modelo. Rever a seleção das opções do modelo para garantir que a seleção do nível de área está correta." } diff --git a/tests/testthat/test-04-model-frame.R b/tests/testthat/test-04-model-frame.R index 9ee5fbd4..bdfe451e 100644 --- a/tests/testthat/test-04-model-frame.R +++ b/tests/testthat/test-04-model-frame.R @@ -54,7 +54,6 @@ test_that("artnum_mf() works with single quarter ART data", { test_that("Informative error displayed when model run to admin level higher/lower than population data supplied", { - x <- expect_error( naomi_model_frame(a_area_merged, demo_population_agesex, @@ -67,11 +66,12 @@ test_that("Informative error displayed when model run to admin level higher/lowe calendar_quarter4 = "CY2022Q3", calendar_quarter5 = "CY2023Q3")) - - expect_equal(x$message, - "Population data not available for admin level selected for model projections.\n Please review model options selection to ensure that area level selection is correct." + expect_equal( + x$message, + paste("Population data not available for admin level selected", + "for model projections. Please review model options", + "selection to ensure that area level selection is correct.") ) - }) test_that("population calibration options", {