mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 04:42:09 +02:00
(v2.1.1.9269) Support 7 new languages
This commit is contained in:
@ -1190,6 +1190,13 @@ message_not_thrown_before <- function(fn, ..., entire_session = FALSE) {
|
||||
not_thrown_before
|
||||
}
|
||||
|
||||
reset_all_thrown_messages <- function() {
|
||||
rm(
|
||||
list = grep("^thrown_msg", ls(envir = AMR_env), value = TRUE),
|
||||
envir = AMR_env
|
||||
)
|
||||
}
|
||||
|
||||
has_colour <- function() {
|
||||
if (is.null(AMR_env$supports_colour)) {
|
||||
if (Sys.getenv("EMACS") != "" || Sys.getenv("INSIDE_EMACS") != "") {
|
||||
|
@ -44,7 +44,7 @@
|
||||
#' * `AMR_substitute_missing_r_breakpoint` \cr A [logical] to use in [as.sir()], to indicate that missing R breakpoints must be substituted with `"R"` - the default is `FALSE`.
|
||||
#' * `AMR_include_screening` \cr A [logical] to use in [as.sir()], to indicate that clinical breakpoints for screening are allowed - the default is `FALSE`.
|
||||
#' * `AMR_keep_synonyms` \cr A [logical] to use in [as.mo()] and all [`mo_*`][mo_property()] functions, to indicate if old, previously valid taxonomic names must be preserved and not be corrected to currently accepted names. The default is `FALSE`.
|
||||
#' * `AMR_locale` \cr A [character] to set the language for the `AMR` package, can be one of these supported language names or ISO-639-1 codes: `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. The default is the current system language (if supported, English otherwise).
|
||||
#' * `AMR_locale` \cr A [character] to set the language for the `AMR` package, can be one of these supported language names or [ISO 639-1 codes](https://en.wikipedia.org/wiki/ISO_639-1): `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. The default is the current system language (if supported, English otherwise).
|
||||
#' * `AMR_mo_source` \cr A file location for a manual code list to be used in [as.mo()] and all [`mo_*`][mo_property()] functions. This is explained in [set_mo_source()].
|
||||
#'
|
||||
#' @section Saving Settings Between Sessions:
|
||||
|
@ -31,7 +31,7 @@
|
||||
#'
|
||||
#' @description These functions allow for filtering rows and selecting columns based on antimicrobial test results that are of a specific antimicrobial class or group, without the need to define the columns or antimicrobial abbreviations. They can be used in base \R, tidyverse, tidymodels, and `data.table`.
|
||||
#'
|
||||
#' In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up using:
|
||||
#' Simply puy, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class, code or name: column names "cefazolin", "kefzol", "CZO" and "J01DB04" would all be included in the following selection:
|
||||
#'
|
||||
#' ```r
|
||||
#' library(dplyr)
|
||||
|
@ -90,7 +90,7 @@
|
||||
#' autoplot(some_mic_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' # support for 20 languages, various guidelines, and many options
|
||||
#' # support for 27 languages, various guidelines, and many options
|
||||
#' autoplot(some_disk_values,
|
||||
#' mo = "Escherichia coli", ab = "cipro",
|
||||
#' guideline = "CLSI 2024", language = "no",
|
||||
@ -207,7 +207,7 @@
|
||||
#' scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") +
|
||||
#' scale_colour_sir(
|
||||
#' language = "pt",
|
||||
#' name = "Support in 20 languages"
|
||||
#' name = "Support in 27 languages"
|
||||
#' )
|
||||
#' }
|
||||
#' }
|
||||
|
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
@ -31,7 +31,7 @@
|
||||
#'
|
||||
#' For language-dependent output of `AMR` functions, such as [mo_name()], [mo_gramstain()], [mo_type()] and [ab_name()].
|
||||
#' @param x Text to translate.
|
||||
#' @param language Language to choose. Use one of these supported language names or ISO-639-1 codes: `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`.
|
||||
#' @param language Language to choose. Use one of these supported language names or [ISO 639-1 codes](https://en.wikipedia.org/wiki/ISO_639-1): `r vector_or(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`.
|
||||
#' @details The currently `r length(LANGUAGES_SUPPORTED)` supported languages are `r vector_and(paste0(sapply(LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]), " (" , LANGUAGES_SUPPORTED, ")"), quotes = FALSE, sort = FALSE)`. All these languages have translations available for all antimicrobial drugs and colloquial microorganism names.
|
||||
#'
|
||||
#' To permanently silence the once-per-session language note on a non-English operating system, you can set the package option [`AMR_locale`][AMR-options] in your `.Rprofile` file like this:
|
||||
@ -75,7 +75,7 @@
|
||||
#' ab_name("Ciprofloxacin")
|
||||
#' mo_name("Coagulase-negative Staphylococcus (CoNS)")
|
||||
#'
|
||||
#' # set_AMR_locale() understands endonyms, English exonyms, and ISO-639-1:
|
||||
#' # set_AMR_locale() understands endonyms, English exonyms, and ISO 639-1:
|
||||
#' set_AMR_locale("Deutsch")
|
||||
#' set_AMR_locale("German")
|
||||
#' set_AMR_locale("de")
|
||||
@ -152,7 +152,7 @@ validate_language <- function(language, extra_txt = character(0)) {
|
||||
}
|
||||
lang <- find_language(language[1], fallback = FALSE)
|
||||
stop_ifnot(length(lang) > 0 && lang %in% LANGUAGES_SUPPORTED,
|
||||
"unsupported language for AMR package", extra_txt, ": \"", language, "\". Use one of these language names or ISO-639-1 codes: ",
|
||||
"unsupported language for AMR package", extra_txt, ": \"", language, "\". Use one of these language names or ISO 639-1 codes: ",
|
||||
paste0('"', vapply(FUN.VALUE = character(1), LANGUAGES_SUPPORTED_NAMES, function(x) x[[1]]),
|
||||
'" ("', LANGUAGES_SUPPORTED, '")',
|
||||
collapse = ", "
|
||||
@ -193,7 +193,7 @@ translate_into_language <- function(from,
|
||||
only_unknown = FALSE,
|
||||
only_affect_ab_names = FALSE,
|
||||
only_affect_mo_names = FALSE) {
|
||||
# get ISO-639-1 of language
|
||||
# get ISO 639-1 of language
|
||||
lang <- validate_language(language)
|
||||
if (lang == "en") {
|
||||
# don' translate
|
||||
|
Reference in New Issue
Block a user