mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 00:10:57 +01:00
82 lines
4.1 KiB
R
82 lines
4.1 KiB
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/translate.R
|
|
\name{translate}
|
|
\alias{translate}
|
|
\alias{get_AMR_locale}
|
|
\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(language)
|
|
|
|
reset_AMR_locale()
|
|
|
|
translate_AMR(x, language = get_AMR_locale())
|
|
}
|
|
\arguments{
|
|
\item{language}{Language to choose. Use one of these supported language names or \href{https://en.wikipedia.org/wiki/ISO_639-1}{ISO 639-1 codes}: English (en), Arabic (ar), Bengali (bn), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), Finnish (fi), French (fr), German (de), Greek (el), Hindi (hi), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swahili (sw), Swedish (sv), Turkish (tr), Ukrainian (uk), Urdu (ur), or Vietnamese (vi).}
|
|
|
|
\item{x}{Text to translate.}
|
|
}
|
|
\description{
|
|
For language-dependent output of \code{AMR} functions, such as \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{
|
|
The currently 28 supported languages are English (en), Arabic (ar), Bengali (bn), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), Finnish (fi), French (fr), German (de), Greek (el), Hindi (hi), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swahili (sw), Swedish (sv), Turkish (tr), Ukrainian (uk), Urdu (ur), and Vietnamese (vi). 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 \code{\link[=AMR-options]{AMR_locale}} in your \code{.Rprofile} file like this:
|
|
|
|
\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Open .Rprofile file
|
|
utils::file.edit("~/.Rprofile")
|
|
|
|
# Then add e.g. Italian support to that file using:
|
|
options(AMR_locale = "Italian")
|
|
}\if{html}{\out{</div>}}
|
|
|
|
And then save the file.
|
|
|
|
Please read about adding or updating a language in \href{https://github.com/msberends/AMR/wiki/}{our Wiki}.
|
|
\subsection{Changing the Default Language}{
|
|
|
|
The system language will be used at default, if that language is supported. The language to be used is determined in this order:
|
|
\enumerate{
|
|
\item The package option \code{\link[=AMR-options]{AMR_locale}}, set by using e.g. \code{set_AMR_locale("German")} or by running e.g. \code{options(AMR_locale = "German")}.
|
|
|
|
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. Run \code{utils::file.edit("~/.Rprofile")} to edit your \code{.Rprofile} file.
|
|
\item The system variable \code{LANG}, as returned by \code{Sys.getenv("LANG")}, e.g. set by adding \code{LANG="de_DE.utf8"} to your \code{.Renviron} file in your home directory.
|
|
\item The system variable \code{LANGUAGE}, but only if \code{LANG} is not set. Note that \code{LANG} is set on most Linux and macOS systems, in which case \code{LANGUAGE} has no effect.
|
|
\item The system locale, as returned by \code{\link[=Sys.getlocale]{Sys.getlocale("LC_COLLATE")}}, if neither \code{LANG} nor \code{LANGUAGE} is set.
|
|
}
|
|
|
|
Thus, if the package option \code{\link[=AMR-options]{AMR_locale}} is set, the system variables \code{LANG} and \code{LANGUAGE} will be ignored.
|
|
}
|
|
}
|
|
\examples{
|
|
# Current settings (based on system language)
|
|
ab_name("Ciprofloxacin")
|
|
mo_name("Coagulase-negative Staphylococcus (CoNS)")
|
|
|
|
# setting another language
|
|
set_AMR_locale("Dutch")
|
|
ab_name("Ciprofloxacin")
|
|
mo_name("Coagulase-negative Staphylococcus (CoNS)")
|
|
|
|
# setting yet another language
|
|
set_AMR_locale("German")
|
|
ab_name("Ciprofloxacin")
|
|
mo_name("Coagulase-negative Staphylococcus (CoNS)")
|
|
|
|
# set_AMR_locale() understands endonyms, English exonyms, and ISO 639-1:
|
|
set_AMR_locale("Deutsch")
|
|
set_AMR_locale("German")
|
|
set_AMR_locale("de")
|
|
ab_name("amox/clav")
|
|
|
|
# reset to system default
|
|
reset_AMR_locale()
|
|
ab_name("amox/clav")
|
|
}
|