diff --git a/.Rbuildignore b/.Rbuildignore index 25b9f7aee..6ce052f9c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -19,13 +19,11 @@ vignettes man/figures/ ^tests/manual_tests$ ^inst/translations$ -tests/testthat/_snaps tests/testthat/postgres.R tests/testthat/postgres-2.R tests/testthat/test-col_schema.R tests/testthat/test-column_roles.R tests/testthat/test-create_validation_steps.R -tests/testthat/test-draft_validation.R tests/testthat/test-expectation_fns.R tests/testthat/test-file_naming.R tests/testthat/test-get_agent_report.R @@ -34,6 +32,7 @@ tests/testthat/test-get_informant_report.R tests/testthat/test-get_multiagent_report.R tests/testthat/test-interrogate_simple.R tests/testthat/test-interrogate_with_agent.R +tests/testthat/_snaps/interrogate_with_agent.md tests/testthat/test-interrogate_with_agent_db.R tests/testthat/test-interrogate_with_agent_segments.R tests/testthat/test-read_disk_multiagent.R diff --git a/R/scan_data.R b/R/scan_data.R index 13af4c144..8e05e3346 100644 --- a/R/scan_data.R +++ b/R/scan_data.R @@ -455,6 +455,7 @@ probe_columns <- function( lang = lang, locale = locale ), + ordered = , factor = probe_columns_factor( data = data, column = col_name, diff --git a/R/tbl_from_file.R b/R/tbl_from_file.R index 46bfb7509..5079f7b29 100644 --- a/R/tbl_from_file.R +++ b/R/tbl_from_file.R @@ -575,33 +575,15 @@ download_remote_file <- function(url, ...) { if (grepl("^https?://", url)) { - is_r32 <- getRversion() >= "3.2" - if (.Platform$OS.type == "windows") { - if (is_r32) { - - method <- "wininet" - - } else { - - seti2 <- utils::"setInternet2" - internet2_start <- seti2(NA) - - if (!internet2_start) { - - on.exit(suppressWarnings(seti2(internet2_start))) - suppressWarnings(seti2(TRUE)) - } - - method <- "internal" - } + method <- "wininet" suppressWarnings(utils::download.file(url, method = method, ...)) } else { - if (is_r32 && capabilities("libcurl")) { + if (capabilities("libcurl")) { method <- "libcurl" diff --git a/data-raw/00-reencode_text.R b/data-raw/00-reencode_text.R index b204d09c7..eefca52fb 100644 --- a/data-raw/00-reencode_text.R +++ b/data-raw/00-reencode_text.R @@ -1,61 +1,5 @@ -library(tidyverse) -library(here) library(yaml) -library(stringi) -reencode_utf8 <- function(x) { +y <- yaml::read_yaml(here::here("data-raw/translations_source.yml"), fileEncoding = "UTF-8") - # Ensure that we encode non-UTF-8 strings to UTF-8 in a - # two-step process: (1) to native encoding, and then - # (2) to UTF-8 - if (Encoding(x) != 'UTF-8') { - x <- enc2utf8(x) - } - - # Use `iconv()` to convert to UTF-32 (big endian) as - # raw bytes and convert again to integer (crucial here - # to set the base to 16 for this conversion) - raw_bytes <- - iconv(x, "UTF-8", "UTF-32BE", toRaw = TRUE) %>% - unlist() %>% - strtoi(base = 16L) - - # Split into a list of four bytes per element - chars <- split(raw_bytes, ceiling(seq_along(raw_bytes) / 4)) - - x <- - vapply( - chars, - FUN.VALUE = character(1), - USE.NAMES = FALSE, - FUN = function(x) { - - bytes_nz <- x[min(which(x > 0)):length(x)] - - if (length(bytes_nz) > 2) { - out <- paste("\\U", paste(as.hexmode(x), collapse = ""), sep = "") - } else if (length(bytes_nz) > 1) { - out <- paste("\\u", paste(as.hexmode(bytes_nz), collapse = ""), sep = "") - } else if (length(bytes_nz) == 1 && bytes_nz > 127) { - out <- paste("\\u", sprintf("%04s", paste(as.hexmode(bytes_nz)), collapse = ""), sep = "") - } else { - out <- rawToChar(as.raw(bytes_nz)) - } - out - } - ) %>% - paste(collapse = "") - - x -} - -y <- yaml::read_yaml(here::here("data-raw/translations_source.yml")) - -# Obtain a list that reencodes all translation text to Unicode -# code points -translations_list <- - lapply(y, lapply, lapply, function(x) { - reencode_utf8(x) %>% stringi::stri_unescape_unicode() - }) - -saveRDS(translations_list, file = here("inst/text/translations_built")) +saveRDS(y, file = here::here("inst/text/translations_built")) diff --git a/data-raw/translations_source.yml b/data-raw/translations_source.yml index 6c0278cd4..13e5109ba 100644 --- a/data-raw/translations_source.yml +++ b/data-raw/translations_source.yml @@ -1531,7 +1531,7 @@ table_scan: nl: "**pointblank** Versie" tbl_lab_r_version: en: "**R** Version" - fr: "version **R**" + fr: "Version **R**" de: "**R** Version" it: "versione **R**" es: "Versión **R**" @@ -1545,7 +1545,7 @@ table_scan: nl: "**R**-versie" tbl_lab_system_os: en: "Operating System" - fr: "Système opérateur" + fr: "Système d'exploitation" de: "Betriebssystem" it: "Sistema operativo" es: "Sistema operativo" @@ -1559,7 +1559,7 @@ table_scan: nl: "Besturingssysteem" tbl_lab_distinct: en: "Distinct" - fr: "valeurs uniques" + fr: "Valeurs uniques" de: "Einzigartige Werte" it: "Valori unici" es: "Valores únicos" @@ -1782,19 +1782,19 @@ table_scan: sv: "Andra värden" nl: "Andere waarden" footer_text_fragment: - en: "Table scan generated with pointblank." - fr: "Scan de tableau généré avec pointblank." - de: "Mit pointblank generierter Scan der Tabelle." - it: "Scansione della tabella generata con pointblank." - es: "Escaneo de Tabla generado con pointblank." - pt: "Examen da tabela gerada com pointblank." - tr: "pointblank ile oluşturulan tablo taraması." - zh: "通过 pointblank建立表扫描。" - ru: "Сканирование таблиц, сгенерированное с помощью pointblank." - pl: "Skan tabeli wygenerowany za pomoca pointblank." - da: "Scan af tabel genereret med pointblank." - sv: "Genomsökning av tabellen genereras med pointblank." - nl: "Scan van tabel gegenereerd met pointblank." + en: "Table scan generated with pointblank." + fr: "Scan de tableau généré avec pointblank." + de: "Mit pointblank generierter Scan der Tabelle." + it: "Scansione della tabella generata con pointblank." + es: "Escaneo de Tabla generado con pointblank." + pt: "Examen da tabela gerada com pointblank." + tr: "pointblank ile oluşturulan tablo taraması." + zh: "通过 pointblank建立表扫描。" + ru: "Сканирование таблиц, сгенерированное с помощью pointblank." + pl: "Skan tabeli wygenerowany za pomoca pointblank." + da: "Scan af tabel genereret med pointblank." + sv: "Genomsökning av tabellen genereras med pointblank." + nl: "Scan van tabel gegenereerd met pointblank." multiagent_report: pointblank_multiagent_title_text: en: "Pointblank Validation Series" diff --git a/inst/text/translations_built b/inst/text/translations_built index 60b68287d..245eb2e02 100644 Binary files a/inst/text/translations_built and b/inst/text/translations_built differ diff --git a/inst/translations/ES/_pkgdown.yml b/inst/translations/ES/_pkgdown.yml index 3984087dc..f8e538bfb 100644 --- a/inst/translations/ES/_pkgdown.yml +++ b/inst/translations/ES/_pkgdown.yml @@ -5,7 +5,7 @@ lang: es home: strip_header: true -url: https://rich-iannone.github.io/pointblank/es +url: https://rstudio.github.io/pointblank/es template: bootstrap: 5 @@ -87,7 +87,7 @@ reference: - conjointly - serially - specially - + - title: Funciones de información desc: > Podemos añadir progresivamente información a un objeto *informant* @@ -112,7 +112,7 @@ reference: - snip_stats - snip_lowest - snip_highest - + - title: Creación de correo electrónico desc: > A veces queremos enviar por correo electrónico un informe de una @@ -125,7 +125,7 @@ reference: - email_create - stock_msg_body - stock_msg_footer - + - title: Registro desc: > El registro de las condiciones de fallo de validación es una buena @@ -149,7 +149,7 @@ reference: contents: - interrogate - get_agent_report - + - title: "El informante: incorporar e informar" desc: > Si tenemos un objeto *informante* que ha sido cargado con información @@ -161,7 +161,7 @@ reference: contents: - incorporate - get_informant_report - + - title: Después del interrogatorio desc: > El objeto `agente` siempre tiene una lista especial llamada 'x-list'. @@ -180,7 +180,7 @@ reference: - get_sundered_data - all_passed - write_testthat_file - + - title: Operaciones con objetos desc: > Tenemos opciones para escribir un agente o informante en el disco con @@ -201,7 +201,7 @@ reference: - activate_steps - deactivate_steps - remove_steps - + - title: El Multiagente desc: > El objeto `multiagente` es un grupo de agentes, cada uno de los @@ -218,7 +218,7 @@ reference: - create_multiagent - read_disk_multiagent - get_multiagent_report - + - title: pointblank YAML desc: > Los archivos YAML pueden ser utilizados en **pointblank** para dos @@ -238,7 +238,7 @@ reference: - yaml_agent_show_exprs - yaml_informant_incorporate - yaml_exec - + - title: Table Transformers desc: > Las funciones del **Table Transformers** pueden transformar @@ -259,7 +259,7 @@ reference: - tt_time_shift - tt_time_slice - get_tt_param - + - title: Funciones de utilidad y ayuda contents: - col_schema @@ -268,7 +268,7 @@ reference: - affix_datetime - stop_if_not - from_github - + - title: Conjuntos de datos contents: - small_table @@ -276,7 +276,7 @@ reference: - specifications - game_revenue - game_revenue_info - + navbar: type: default left: @@ -307,7 +307,7 @@ navbar: - text: News href: news/index.html - text: In English - href: https://rich-iannone.github.io/pointblank + href: https://rstudio.github.io/pointblank development: version_tooltip: "Development version" diff --git a/inst/translations/ES/vignettes/INFO-1.Rmd b/inst/translations/ES/vignettes/INFO-1.Rmd index 6eaaba787..bcaa4236b 100644 --- a/inst/translations/ES/vignettes/INFO-1.Rmd +++ b/inst/translations/ES/vignettes/INFO-1.Rmd @@ -78,7 +78,7 @@ informant <- section_name = "further information", `examples and documentation` = "Examples for how to use the `info_*()` functions (and many more) are available at the - [**pointblank** site](https://rich-iannone.github.io/pointblank/)." + [**pointblank** site](https://rstudio.github.io/pointblank/)." ) informant diff --git a/inst/translations/ES/vignettes/VALID-V.Rmd b/inst/translations/ES/vignettes/VALID-V.Rmd index 732bb16c0..b914f50cd 100644 --- a/inst/translations/ES/vignettes/VALID-V.Rmd +++ b/inst/translations/ES/vignettes/VALID-V.Rmd @@ -43,6 +43,6 @@ Just as with all the other workflows, the `tbl` supplied could be a data frame, # Languages and Locales -The reporting generated by `scan_data()` can be presented in one of eight spoken languages: English (`"en"`, the default), French (`"fr"`), German (`"de"`), Italian (`"it"`), Spanish (`"es"`), Portuguese, (`"pt"`), Chinese (`"zh"`), and Russian (`"ru"`). These two-letter language codes can be used as an argument to the `lang` argument. When applied, all label text and other non-data elements will be set to the language of choice. We have checked the translations with native speakers of the respective languages but if you find an error that should be corrected, please [file an issue](https://github.com/rich-iannone/pointblank/issues). +The reporting generated by `scan_data()` can be presented in one of eight spoken languages: English (`"en"`, the default), French (`"fr"`), German (`"de"`), Italian (`"it"`), Spanish (`"es"`), Portuguese, (`"pt"`), Chinese (`"zh"`), and Russian (`"ru"`). These two-letter language codes can be used as an argument to the `lang` argument. When applied, all label text and other non-data elements will be set to the language of choice. We have checked the translations with native speakers of the respective languages but if you find an error that should be corrected, please [file an issue](https://github.com/rstudio/pointblank/issues). Along with translations, numerical values that are generated as part of the reporting (e.g., table dimensions, summary statistics, etc.) are automatically formatted in the locale of the language (given in `lang`). This can be overridden with the `locale` argument which accepts a locale ID. Examples include `"en_US"` for English (United States) and `"fr_FR"` for French (France). More simply, this can be a language identifier without a country designation, like `"es"` for Spanish (Spain, same as `"es_ES"`). More than 700 locales are currently accepted. diff --git a/tests/testthat/_snaps/draft_validation.md b/tests/testthat/_snaps/draft_validation.md index cb5052b95..a80d2f82a 100644 --- a/tests/testthat/_snaps/draft_validation.md +++ b/tests/testthat/_snaps/draft_validation.md @@ -283,7 +283,7 @@ Code readLines(con = path) %>% paste0(collapse = "\n") Output - [1] "library(pointblank)\n\nagent <-\n create_agent(\n tbl = ~ tbl,\n actions = action_levels(\n warn_at = 0.05,\n stop_at = 0.10\n ),\n tbl_name = \"tbl\",\n label = \"Validation plan generated by `draft_validation()`.\",\n lang = \"fr\",\n locale = \"fr\"\n ) %>%\n # Attendez-vous à ce que la colonne `a` soit de type: integer\n col_is_integer(\n columns = c(\"a\")\n ) %>%\n # Attendez-vous à ce que les valeurs de `a` soient comprises entre `1` et `8`\n col_vals_between(\n columns = c(\"a\"),\n left = 1,\n right = 8\n ) %>%\n # Attendez-vous à ce que la colonne `b` soit de type: character\n col_is_character(\n columns = c(\"b\")\n ) %>%\n # Attendez-vous à ce que la colonne `c` soit de type: numeric\n col_is_numeric(\n columns = c(\"c\")\n ) %>%\n # Attendez-vous à ce que les valeurs de `c` soient comprises entre `2` et `9`\n col_vals_between(\n columns = c(\"c\"),\n left = 2,\n right = 9,\n na_pass = TRUE\n ) %>%\n # Attendez-vous à ce que la colonne `d` soit de type: numeric\n col_is_numeric(\n columns = c(\"d\")\n ) %>%\n # Attendez-vous à ce que les valeurs de `d` soient comprises entre `108.34` et `9999.99`\n col_vals_between(\n columns = c(\"d\"),\n left = 108.34,\n right = 9999.99\n ) %>%\n # Attendez-vous à ce que la colonne `e` soit de type: logical\n col_is_logical(\n columns = c(\"e\")\n ) %>%\n # Attendez-vous à ce que la colonne `f` soit de type: character\n col_is_character(\n columns = c(\"f\")\n ) %>%\n # Attendez-vous à ce que les schémas de colonnes correspondent\n col_schema_match(\n schema = col_schema(\n date_time = c(\"POSIXct\", \"POSIXt\"),\n date = \"Date\",\n a = \"integer\",\n b = \"character\",\n c = \"numeric\",\n d = \"numeric\",\n e = \"logical\",\n f = \"character\"\n )\n ) %>%\n interrogate()\n\nagent" + [1] "library(pointblank)\n\nagent <-\n create_agent(\n tbl = ~ tbl,\n actions = action_levels(\n warn_at = 0.05,\n stop_at = 0.10\n ),\n tbl_name = \"tbl\",\n label = \"Validation plan generated by `draft_validation()`.\",\n lang = \"fr\",\n locale = \"fr\"\n ) %>%\n # On s'attend à ce que la colonne `a` soit de type : integer\n col_is_integer(\n columns = c(\"a\")\n ) %>%\n # On s'attend à ce que les valeurs de `a` soient comprises entre `1` et `8`\n col_vals_between(\n columns = c(\"a\"),\n left = 1,\n right = 8\n ) %>%\n # On s'attend à ce que la colonne `b` soit de type : character\n col_is_character(\n columns = c(\"b\")\n ) %>%\n # On s'attend à ce que la colonne `c` soit de type : numeric\n col_is_numeric(\n columns = c(\"c\")\n ) %>%\n # On s'attend à ce que les valeurs de `c` soient comprises entre `2` et `9`\n col_vals_between(\n columns = c(\"c\"),\n left = 2,\n right = 9,\n na_pass = TRUE\n ) %>%\n # On s'attend à ce que la colonne `d` soit de type : numeric\n col_is_numeric(\n columns = c(\"d\")\n ) %>%\n # On s'attend à ce que les valeurs de `d` soient comprises entre `108.34` et `9999.99`\n col_vals_between(\n columns = c(\"d\"),\n left = 108.34,\n right = 9999.99\n ) %>%\n # On s'attend à ce que la colonne `e` soit de type : logical\n col_is_logical(\n columns = c(\"e\")\n ) %>%\n # On s'attend à ce que la colonne `f` soit de type : character\n col_is_character(\n columns = c(\"f\")\n ) %>%\n # On s'attend à ce que les schémas de colonnes correspondent\n col_schema_match(\n schema = col_schema(\n date_time = c(\"POSIXct\", \"POSIXt\"),\n date = \"Date\",\n a = \"integer\",\n b = \"character\",\n c = \"numeric\",\n d = \"numeric\",\n e = \"logical\",\n f = \"character\"\n )\n ) %>%\n interrogate()\n\nagent" --- diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index aa01efa8c..3d0fceee3 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -4,3 +4,8 @@ expect_equal_unlist <- function(object, expected, ...) { expected ) } + +skip_if_not_utf8 <- function() { + # likely on Windows for R < 4.2 + skip_if_not(l10n_info()$`UTF-8`) +} diff --git a/tests/testthat/test-draft_validation.R b/tests/testthat/test-draft_validation.R index 9612a5918..e5e21d4ee 100644 --- a/tests/testthat/test-draft_validation.R +++ b/tests/testthat/test-draft_validation.R @@ -1,5 +1,4 @@ -skip_on_os(os = "windows") - +skip_on_cran() work_path <- "./generated_r_files" if (fs::dir_exists(path = work_path)) { @@ -92,7 +91,7 @@ test_that("draft validations for data tables can be generated", { }) test_that("draft validations for data tables can be generated in different languages", { - + skip_if_not_utf8() write_draft_snapshot_test(dataset = pointblank::small_table, filename = "st_en", lang = "en") write_draft_snapshot_test(dataset = pointblank::small_table, filename = "st_fr", lang = "fr") write_draft_snapshot_test(dataset = pointblank::small_table, filename = "st_de", lang = "de")