From 69c026885adbb828ee81a8adc8f6db7be42f9e24 Mon Sep 17 00:00:00 2001 From: nfrerebeau Date: Mon, 16 Dec 2024 19:21:40 +0100 Subject: [PATCH] Translate into French --- R/diversity_alpha.R | 24 +++--- R/plot_diceleraas.R | 3 +- R/plot_diversity.R | 16 ++-- R/plot_rank.R | 4 +- R/rarefaction.R | 4 +- R/statistics.R | 8 +- R/tabula-internal.R | 5 ++ README.Rmd | 2 +- README.md | 2 +- inst/po/fr/LC_MESSAGES/R-tabula.mo | Bin 0 -> 1776 bytes .../_tinysnapshot/plot_dice_leraas.svg | 2 +- inst/tinytest/test_diversity.R | 2 + inst/tinytest/test_plots.R | 2 + inst/tinytest/test_rarefaction.R | 2 + inst/tinytest/test_richness.R | 2 + po/R-fr.po | 80 ++++++++++++++++++ po/R-tabula.pot | 77 +++++++++++++++++ 17 files changed, 204 insertions(+), 31 deletions(-) create mode 100644 inst/po/fr/LC_MESSAGES/R-tabula.mo create mode 100644 po/R-fr.po create mode 100644 po/R-tabula.pot diff --git a/R/diversity_alpha.R b/R/diversity_alpha.R index 4cc4734b..8e5ece28 100644 --- a/R/diversity_alpha.R +++ b/R/diversity_alpha.R @@ -59,8 +59,8 @@ setMethod( F1 <- sum(x == 1) # Number of singleton species if (F1 == N_rare) - stop("ACE is undefined when all rare species are singletons, ", - "consider using the bias-corrected Chao1 index instead.", + stop(tr_("ACE is undefined when all rare species are singletons."), + tr_("Consider using the bias-corrected Chao1 estimator instead."), call. = FALSE) ## Sample coverage estimate for rare species @@ -186,11 +186,13 @@ setMethod( } } if (improved) { - f3 <- sum(x == 3) # Number of tripleton species - f4 <- sum(x == 4) # Number of quadrupleton species + f3 <- sum(x == 3) # Number of triple species + f4 <- sum(x == 4) # Number of quadruple species if (f4 == 0) - stop("Improved Chao1 estimator is undefined ", - "when there is no quadrupleton species.", call. = FALSE) + stop( + tr_("Improved Chao1 estimator is undefined when there is no quadruple species."), + call. = FALSE + ) k <- f1 - ((N - 3) / (N - 1)) * ((f2 * f3) / (2 * f4)) D <- D + ((N - 3) / N) * (f3 / (4 * f4)) * max(k, 0) @@ -230,8 +232,10 @@ setMethod( q3 <- sum(q == 3) # Number of triple species q4 <- sum(q == 4) # Number of quadruple species if (q4 == 0) - stop("Improved Chao2 estimator is undefined ", - "when there is no quadruple species.", call. = FALSE) + stop( + tr_("Improved Chao2 estimator is undefined when there is no quadruple species."), + call. = FALSE + ) k <- q1 - ((t - 3) / (t - 1)) * ((q2 * q3) / (2 * q4)) D <- D + ((t - 3) / (4 * t)) * (q3 / q4) * max(k, 0) @@ -262,8 +266,8 @@ setMethod( q1 <- sum(q == 1) # Number of unique species in the assemblage if (q1 == N_infr) - stop("ICE is undefined when all infrequent species are unique, ", - "consider using the bias-corrected Chao2 estimator instead.", + stop(tr_("ICE is undefined when all rare species are singletons."), + tr_("Consider using the bias-corrected Chao2 estimator instead."), call. = FALSE) ## Sample coverage estimate diff --git a/R/plot_diceleraas.R b/R/plot_diceleraas.R index a0c0fe00..3fc8c91f 100644 --- a/R/plot_diceleraas.R +++ b/R/plot_diceleraas.R @@ -110,7 +110,8 @@ setMethod( ## Add annotation if (ann) { - graphics::title(main = main, sub = sub, xlab = "Count", ylab = NULL, ...) + graphics::title(main = main, sub = sub, + xlab = tr_("Absolute frequency"), ylab = NULL, ...) } invisible(object) diff --git a/R/plot_diversity.R b/R/plot_diversity.R index 87254527..1997e36a 100644 --- a/R/plot_diversity.R +++ b/R/plot_diversity.R @@ -65,12 +65,12 @@ plot.DiversityIndex <- function(x, log = "x", if (ann) { y_lab <- switch ( class(x), - HeterogeneityIndex = "Heterogeneity", - EvennessIndex = "Evenness", - RichnessIndex = "Richness", - "Diversity" + HeterogeneityIndex = tr_("Heterogeneity"), + EvennessIndex = tr_("Evenness"), + RichnessIndex = tr_("Richness"), + tr_("Diversity") ) - graphics::title(main = main, sub = sub, xlab = "Sample size", + graphics::title(main = main, sub = sub, xlab = tr_("Sample size"), ylab = sprintf("%s (%s)", y_lab, x@method)) } @@ -134,8 +134,8 @@ setMethod( ## Add annotation if (ann) { - graphics::title(main = main, sub = sub, xlab = "Sample size", - ylab = "Diversity", ...) + graphics::title(main = main, sub = sub, xlab = tr_("Sample size"), + ylab = tr_("Diversity"), ...) } ## Legend @@ -270,7 +270,7 @@ setMethod( ## Add annotation if (ann) { graphics::title(main = main, sub = sub, xlab = "alpha", - ylab = "Diversity", ...) + ylab = tr_("Diversity"), ...) } ## Legend diff --git a/R/plot_rank.R b/R/plot_rank.R index d939da7f..120a5df8 100644 --- a/R/plot_rank.R +++ b/R/plot_rank.R @@ -76,8 +76,8 @@ setMethod( ## Add annotation if (ann) { - graphics::title(main = main, sub = sub, xlab = "Rank", - ylab = "Frequency", ...) + graphics::title(main = main, sub = sub, xlab = tr_("Rank"), + ylab = tr_("Frequency"), ...) } ## Legend diff --git a/R/rarefaction.R b/R/rarefaction.R index eb66729b..1399867c 100644 --- a/R/rarefaction.R +++ b/R/rarefaction.R @@ -121,8 +121,8 @@ plot.RarefactionIndex <- function(x, color = NULL, symbol = FALSE, ## Add annotation if (ann) { - graphics::title(main = main, sub = sub, xlab = "Sample size", - ylab = "Expected species index") + graphics::title(main = main, sub = sub, xlab = tr_("Sample size"), + ylab = tr_("Expected species index")) } ## Legend diff --git a/R/statistics.R b/R/statistics.R index 7a69ba3a..2b8a1346 100644 --- a/R/statistics.R +++ b/R/statistics.R @@ -45,13 +45,11 @@ setMethod( #' @noRd combination <- function(n, k) { # Validation - if (!is.numeric(n)) - stop("`n` must be a numeric vector.") - if (!is.numeric(k)) - stop("`k` must be a numeric vector.") + arkhe::assert_scalar(n, "numeric") + arkhe::assert_scalar(k, "numeric") if (n > 170 | k > 170) { - if (getOption("tabula.verbose")) message("Ramanujan approximation of x!") + if (getOption("tabula.verbose")) message(tr_("Ramanujan approximation of x!")) c <- exp(ramanujan(n) - ramanujan(k) - ramanujan(n - k)) } else { c <- factorial(n) / (factorial(k) * factorial(n - k)) diff --git a/R/tabula-internal.R b/R/tabula-internal.R index 2bc54182..00d9a57f 100644 --- a/R/tabula-internal.R +++ b/R/tabula-internal.R @@ -1,5 +1,10 @@ # HELPERS +## https://michaelchirico.github.io/potools/articles/developers.html +tr_ <- function(...) { + enc2utf8(gettext(paste0(...), domain = "R-tabula")) +} + is_incidence <- function(x) { if (is.logical(x)) return(TRUE) x <- as.numeric(x) diff --git a/README.Rmd b/README.Rmd index 136f7991..c10d63ca 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,7 +20,7 @@ Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale [![R-CMD-check](https://github.com/tesselle/tabula/workflows/R-CMD-check/badge.svg)](https://github.com/tesselle/tabula/actions) -[![codecov](https://codecov.io/gh/tesselle/tabula/branch/master/graph/badge.svg)](https://app.codecov.io/gh/tesselle/tabula) +[![codecov](https://codecov.io/gh/tesselle/tabula/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tesselle/tabula) [![CodeFactor](https://www.codefactor.io/repository/github/tesselle/tabula/badge)](https://www.codefactor.io/repository/github/tesselle/tabula) [![Dependencies](https://tinyverse.netlify.app/badge/tabula)](https://cran.r-project.org/package=tabula) diff --git a/README.md b/README.md index 5935e83b..4bec77e2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![R-CMD-check](https://github.com/tesselle/tabula/workflows/R-CMD-check/badge.svg)](https://github.com/tesselle/tabula/actions) -[![codecov](https://codecov.io/gh/tesselle/tabula/branch/master/graph/badge.svg)](https://app.codecov.io/gh/tesselle/tabula) +[![codecov](https://codecov.io/gh/tesselle/tabula/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tesselle/tabula) [![CodeFactor](https://www.codefactor.io/repository/github/tesselle/tabula/badge)](https://www.codefactor.io/repository/github/tesselle/tabula) [![Dependencies](https://tinyverse.netlify.app/badge/tabula)](https://cran.r-project.org/package=tabula) diff --git a/inst/po/fr/LC_MESSAGES/R-tabula.mo b/inst/po/fr/LC_MESSAGES/R-tabula.mo new file mode 100644 index 0000000000000000000000000000000000000000..26dcef22cbe320e2787bef242acdd6fc3ef9ccb2 GIT binary patch literal 1776 zcmb`H&yO256vqveU*V^EfD4CrTM(Kw6HwL7cB@v~ght(#)sk|?nR!VJj-9nVOH!`A zaN^Wkg~W}yRTVdmBlUmirC0t0E~w(`N%lv?9w@~t=i}$GpP!%Kcb}d=cVD2rkNy$* z1N0B$_$B0KD+plJ~%P{u409|8&JaKpbDUI3L@4=y7e#RXp>kVQC$6v~iuf#XBQ(f#d2H zbMZR*+vqV)ac!qd%2Q!-9x1~)eLrDCQfqS3G5Hy1iaph1WyYF=HNGjX4ZYPxU>Z3- zDA;5Rv4amPXGev{LJAY6p^`qytaF?NxZasan-cq=rZQMZ%J{%CZ~n`z?X$LCSBLDp z3JcLaWMkNS(VZjcc-~R)3YVLU-f^TiIIy#0HXQf$|62z7)0wk}XWi-_*+eRkN@Uqs zIw)lBikUu6ZBwjyTD#=)dfJ!fJF%~_Nu7tU{ny zOZu#t;%~FnYBl!0O!oOu#m~ug8Ms63R{QfLZ71nPN;f;L^wU;~b-U7sWZ9epdaOVGxDn$s=aU9qRy1B%I0%!ZlfSiZ9bAxRf_7zgF>M`aBP6tH@V6f(Nn&XTUC+_c!Ruv zu8!^?Zd4_fLt0g7sDLH2b DLH2a DLH1 -Count +Absolute frequency diff --git a/inst/tinytest/test_diversity.R b/inst/tinytest/test_diversity.R index 4f8da381..f5653f28 100644 --- a/inst/tinytest/test_diversity.R +++ b/inst/tinytest/test_diversity.R @@ -1,3 +1,5 @@ +Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale + source("helpers.R") data("cantabria") diff --git a/inst/tinytest/test_plots.R b/inst/tinytest/test_plots.R index 2ae9d19a..d88b587c 100644 --- a/inst/tinytest/test_plots.R +++ b/inst/tinytest/test_plots.R @@ -1,4 +1,6 @@ if (at_home()) { + Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale + source("helpers.R") using("tinysnapshot") options(tinysnapshot_device = "svglite") diff --git a/inst/tinytest/test_rarefaction.R b/inst/tinytest/test_rarefaction.R index d8be9158..9da026f5 100644 --- a/inst/tinytest/test_rarefaction.R +++ b/inst/tinytest/test_rarefaction.R @@ -1,3 +1,5 @@ +Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale + # Data from Magurran 1988, p. 128-129 trap <- matrix(data = c(9, 3, 0, 4, 2, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 2, 0, 5, 3, 0), diff --git a/inst/tinytest/test_richness.R b/inst/tinytest/test_richness.R index c4b2f677..db1f0e7a 100644 --- a/inst/tinytest/test_richness.R +++ b/inst/tinytest/test_richness.R @@ -1,3 +1,5 @@ +Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale + source("helpers.R") data("cantabria") diff --git a/po/R-fr.po b/po/R-fr.po new file mode 100644 index 00000000..0c876d35 --- /dev/null +++ b/po/R-fr.po @@ -0,0 +1,80 @@ +msgid "" +msgstr "" +"Project-Id-Version: tabula 3.1.1.9000\n" +"POT-Creation-Date: 2024-12-16 19:01+0100\n" +"PO-Revision-Date: 2024-12-16 19:01+0100\n" +"Last-Translator: Nicolas Frerebeau \n" +"Language-Team: fr\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: diversity_alpha.R:62 +msgid "ACE is undefined when all rare species are singletons." +msgstr "L'estimateur ACE est indéfini lorsque toutes les espèces rares sont des singletons." + +#: diversity_alpha.R:63 +msgid "Consider using the bias-corrected Chao1 estimator instead." +msgstr "Envisagez plutôt d'utiliser l'estimateur Chao1 non biaisé." + +#: diversity_alpha.R:193 +msgid "" +"Improved Chao1 estimator is undefined when there is no quadruple species." +msgstr "" +"L'estimateur Chao1 amélioré est indéfini lorsqu'il n'y a pas d'espèce quadruple." + +#: diversity_alpha.R:236 +msgid "" +"Improved Chao2 estimator is undefined when there is no quadruple species." +msgstr "" +"L'estimateur Chao2 amélioré est indéfini lorsqu'il n'y a pas d'espèce quadruple." + +#: diversity_alpha.R:269 +msgid "ICE is undefined when all rare species are singletons." +msgstr "L'estimateur ICE est indéfini lorsque toutes les espèces rares sont des singletons." + +#: diversity_alpha.R:270 +msgid "Consider using the bias-corrected Chao2 estimator instead." +msgstr "Envisagez plutôt d'utiliser l'estimateur Chao2 non biaisé." + +#: plot_diceleraas.R:114 +msgid "Absolute frequency" +msgstr "Fréquence absolue" + +#: plot_diversity.R:68 +msgid "Heterogeneity" +msgstr "Hétérogénéité" + +#: plot_diversity.R:69 +msgid "Evenness" +msgstr "Équitabilité" + +#: plot_diversity.R:70 +msgid "Richness" +msgstr "Richesse" + +#: plot_diversity.R:71 plot_diversity.R:138 plot_diversity.R:273 +msgid "Diversity" +msgstr "Diversité" + +#: plot_diversity.R:73 plot_diversity.R:137 rarefaction.R:124 +msgid "Sample size" +msgstr "Effectif" + +#: plot_rank.R:79 +msgid "Rank" +msgstr "Rang" + +#: plot_rank.R:80 +msgid "Frequency" +msgstr "Fréquence" + +#: rarefaction.R:125 +msgid "Expected species index" +msgstr "Indice de diversité attendu" + +#: statistics.R:52 +msgid "Ramanujan approximation of x!" +msgstr "" diff --git a/po/R-tabula.pot b/po/R-tabula.pot new file mode 100644 index 00000000..c19e2ad0 --- /dev/null +++ b/po/R-tabula.pot @@ -0,0 +1,77 @@ +msgid "" +msgstr "" +"Project-Id-Version: tabula 3.1.1.9000\n" +"POT-Creation-Date: 2024-12-16 19:01+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: diversity_alpha.R:62 +msgid "ACE is undefined when all rare species are singletons." +msgstr "" + +#: diversity_alpha.R:63 +msgid "Consider using the bias-corrected Chao1 estimator instead." +msgstr "" + +#: diversity_alpha.R:193 +msgid "" +"Improved Chao1 estimator is undefined when there is no quadruple species." +msgstr "" + +#: diversity_alpha.R:236 +msgid "" +"Improved Chao2 estimator is undefined when there is no quadruple species." +msgstr "" + +#: diversity_alpha.R:269 +msgid "ICE is undefined when all rare species are singletons." +msgstr "" + +#: diversity_alpha.R:270 +msgid "Consider using the bias-corrected Chao2 estimator instead." +msgstr "" + +#: plot_diceleraas.R:114 +msgid "Absolute frequency" +msgstr "" + +#: plot_diversity.R:68 +msgid "Heterogeneity" +msgstr "" + +#: plot_diversity.R:69 +msgid "Evenness" +msgstr "" + +#: plot_diversity.R:70 +msgid "Richness" +msgstr "" + +#: plot_diversity.R:71 plot_diversity.R:138 plot_diversity.R:273 +msgid "Diversity" +msgstr "" + +#: plot_diversity.R:73 plot_diversity.R:137 rarefaction.R:124 +msgid "Sample size" +msgstr "" + +#: plot_rank.R:79 +msgid "Rank" +msgstr "" + +#: plot_rank.R:80 +msgid "Frequency" +msgstr "" + +#: rarefaction.R:125 +msgid "Expected species index" +msgstr "" + +#: statistics.R:52 +msgid "Ramanujan approximation of x!" +msgstr ""