4.1 KiB
Translate Strings from the AMR Package
For language-dependent output of AMR functions, such as
mo_name(),
mo_gramstain(),
mo_type()
and
ab_name().
Usage
get_AMR_locale()
set_AMR_locale(language)
reset_AMR_locale()
translate_AMR(x, language = get_AMR_locale())
Arguments
-
language:
Language to choose. Use one of these supported language names or 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).
-
x:
Text to translate.
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
AMR_locale
in your .Rprofile file like this:
# Open .Rprofile file
utils::file.edit("~/.Rprofile")
# Then add e.g. Italian support to that file using:
options(AMR_locale = "Italian")
And then save the file.
Please read about adding or updating a language in our Wiki.
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:
-
The package option
AMR_locale, set by using e.g.set_AMR_locale("German")or by running e.g.options(AMR_locale = "German").Note that setting an R option only works in the same session. Save the command
options(AMR_locale = "(your language)")to your.Rprofilefile to apply it for every session. Runutils::file.edit("~/.Rprofile")to edit your.Rprofilefile. -
The system variable
LANG, as returned bySys.getenv("LANG"), e.g. set by addingLANG="de_DE.utf8"to your.Renvironfile in your home directory. -
The system variable
LANGUAGE, but only ifLANGis not set. Note thatLANGis set on most Linux and macOS systems, in which caseLANGUAGEhas no effect. -
The system locale, as returned by
Sys.getlocale("LC_COLLATE"), if neitherLANGnorLANGUAGEis set.
Thus, if the package option
AMR_locale
is set, the system variables LANG and 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")