1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 12:31:58 +02:00

language updates

This commit is contained in:
2022-08-19 12:33:14 +02:00
parent 4b19c3dc5e
commit 3f2f60ab77
23 changed files with 543 additions and 506 deletions

View File

@ -32,7 +32,7 @@
mo = NULL,
ab = NULL,
guideline = "EUCAST",
title = paste("MIC values of", deparse(substitute(object))),
title = deparse(substitute(object)),
ylab = "Frequency",
xlab = "Minimum Inhibitory Concentration (mg/L)",
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
@ -61,7 +61,7 @@
object,
mo = NULL,
ab = NULL,
title = paste("Disk zones of", deparse(substitute(object))),
title = deparse(substitute(object)),
ylab = "Frequency",
xlab = "Disk diffusion diameter (mm)",
guideline = "EUCAST",
@ -78,12 +78,13 @@
ylab = "Percentage",
xlab = "Antimicrobial Interpretation",
main = deparse(substitute(x)),
language = get_AMR_locale(),
...
)
\method{autoplot}{rsi}(
object,
title = paste("Resistance Overview of", deparse(substitute(object))),
title = deparse(substitute(object)),
xlab = "Antimicrobial Interpretation",
ylab = "Frequency",
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),

View File

@ -3,25 +3,39 @@
\name{translate}
\alias{translate}
\alias{get_AMR_locale}
\title{Translate Strings from AMR Package}
\alias{set_AMR_locale}
\alias{reset_AMR_locale}
\alias{translate_AMR}
\title{Translate Strings from the AMR Package}
\usage{
get_AMR_locale()
set_AMR_locale(lang)
reset_AMR_locale()
translate_AMR(x, language = get_AMR_locale())
}
\arguments{
\item{lang}{language to choose. Use one of these supported language names or ISO-639-1 codes: "English" ("en"), "Chinese" ("zh"), "Danish" ("da"), "Dutch" ("nl"), "French" ("fr"), "German" ("de"), "Greek" ("el"), "Italian" ("it"), "Japanese" ("ja"), "Polish" ("pl"), "Portuguese" ("pt"), "Russian" ("ru"), "Spanish" ("es"), "Swedish" ("sv"), "Ukrainian" ("uk").}
\item{x}{text to translate}
}
\description{
For language-dependent output of AMR functions, like \code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}} and \code{\link[=ab_name]{ab_name()}}.
}
\details{
Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: \url{https://github.com/msberends/AMR/blob/main/data-raw/translations.tsv}. This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_*}} functions (such as \code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.) and \code{\link[=ab_property]{ab_*}} functions (such as \code{\link[=ab_name]{ab_name()}}, \code{\link[=ab_group]{ab_group()}}, etc.).
The currently 15 supported languages are English, Chinese, Danish, Dutch, French, German, Greek, Italian, Japanese, Polish, Portuguese, Russian, Spanish, Swedish and Ukrainian. All these languages have translations available for all antimicrobial agents and colloquial microorganism names.
Currently supported languages are: Danish, Dutch, English, French, German, Italian, Portuguese, Russian, Spanish and Swedish. All these languages have translations available for all antimicrobial agents and colloquial microorganism names.
Please suggest your own translations \href{https://github.com/msberends/AMR/issues/new?title=Translations}{by creating a new issue on our repository}.
Please suggest your own translations \href{https://github.com/msberends/AMR/issues/new?title=Translations}{by creating a new issue on our repository}. Strings will be translated to foreign languages if they are defined in \href{https://github.com/msberends/AMR/blob/main/data-raw/translations.tsv}{this repository file}. This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_*}} functions (such as \code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.) and \code{\link[=ab_property]{ab_*}} functions (such as \code{\link[=ab_name]{ab_name()}}, \code{\link[=ab_group]{ab_group()}}, etc.).
\subsection{Changing the Default Language}{
The system language will be used at default (as returned by \code{Sys.getenv("LANG")} or, if \code{LANG} is not set, \code{\link[=Sys.getlocale]{Sys.getlocale()}}), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
The system language will be used at default (as returned by \code{Sys.getenv("LANG")} or, if \code{LANG} is not set, \link{Sys.getlocale("LC_COLLATE")}), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
\enumerate{
\item Setting the R option \code{AMR_locale}, e.g. by running \code{options(AMR_locale = "de")}
\item Setting the system variable \code{LANGUAGE} or \code{LANG}, e.g. by adding \code{LANGUAGE="de_DE.utf8"} to your \code{.Renviron} file in your home directory
\item Setting the R option \code{AMR_locale}, either by using \code{set_AMR_locale()} or by running e.g. \code{options(AMR_locale = "de")}.
Note that setting an \R option only works in the same session. Save the command \code{options(AMR_locale = "(your language)")} to your \code{.Rprofile} file to apply it for every session.
\item Setting the system variable \code{LANGUAGE} or \code{LANG}, e.g. by adding \code{LANGUAGE="de_DE.utf8"} to your \code{.Renviron} file in your home directory.
}
Thus, if the R option \code{AMR_locale} is set, the system variables \code{LANGUAGE} and \code{LANG} will be ignored.
@ -41,35 +55,18 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/
}
\examples{
# The 'language' argument of below functions
# will be set automatically to your system language
# with get_AMR_locale()
# Current settings
ab_name("Ciprofloxacin")
mo_name("Coagulase-negative Staphylococcus")
# English
mo_name("CoNS", language = "en")
#> "Coagulase-negative Staphylococcus (CoNS)"
# setting another language
set_AMR_locale("Greek")
ab_name("Ciprofloxacin")
mo_name("Coagulase-negative Staphylococcus")
# Danish
mo_name("CoNS", language = "da")
#> "Koagulase-negative stafylokokker (KNS)"
set_AMR_locale("Spanish")
ab_name("Ciprofloxacin")
mo_name("Coagulase-negative Staphylococcus")
# Dutch
mo_name("CoNS", language = "nl")
#> "Coagulase-negatieve Staphylococcus (CNS)"
# German
mo_name("CoNS", language = "de")
#> "Koagulase-negative Staphylococcus (KNS)"
# Italian
mo_name("CoNS", language = "it")
#> "Staphylococcus negativo coagulasi (CoNS)"
# Portuguese
mo_name("CoNS", language = "pt")
#> "Staphylococcus coagulase negativo (CoNS)"
# Spanish
mo_name("CoNS", language = "es")
#> "Staphylococcus coagulasa negativo (SCN)"
reset_AMR_locale()
}