1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 08:06:12 +01:00
AMR/man/translate.Rd

85 lines
3.9 KiB
Plaintext
Raw Normal View History

2019-05-10 16:44:59 +02:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/translate.R
2019-05-10 16:44:59 +02:00
\name{translate}
\alias{translate}
\alias{get_AMR_locale}
2022-08-19 12:33:14 +02:00
\alias{set_AMR_locale}
\alias{reset_AMR_locale}
\alias{translate_AMR}
\title{Translate Strings from the AMR Package}
2019-05-10 16:44:59 +02:00
\usage{
get_AMR_locale()
2022-08-19 12:33:14 +02:00
2022-08-27 20:49:37 +02:00
set_AMR_locale(language)
2022-08-19 12:33:14 +02:00
reset_AMR_locale()
translate_AMR(x, language = get_AMR_locale())
}
\arguments{
\item{language}{language to choose. Use one of these supported language names or ISO-639-1 codes: English (en), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), Finnish (fi), French (fr), German (de), Greek (el), Italian (it), Japanese (ja), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv), Turkish (tr), or Ukrainian (uk).}
2022-08-19 12:33:14 +02:00
\item{x}{text to translate}
2019-05-10 16:44:59 +02:00
}
\description{
2023-01-23 20:07:57 +01:00
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()}}.
2019-05-10 16:44:59 +02:00
}
\details{
The currently 20 supported languages are English (en), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), Finnish (fi), French (fr), German (de), Greek (el), Italian (it), Japanese (ja), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv), Turkish (tr), and Ukrainian (uk). All these languages have translations available for all antimicrobial drugs and colloquial microorganism names.
2022-10-05 09:12:22 +02:00
To permanently silence the once-per-session language note on a non-English operating system, you can set the \link[=AMR-options]{package option} \code{\link[=AMR-options]{AMR_locale}} in your \code{.Rprofile} file like this:
2022-10-05 09:12:22 +02:00
\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Open .Rprofile file
utils::file.edit("~/.Rprofile")
2022-12-10 10:09:57 +01:00
# Then add e.g. Italian support to that file using:
2022-10-05 09:12:22 +02:00
options(AMR_locale = "Italian")
}\if{html}{\out{</div>}}
2022-10-10 15:44:59 +02:00
And then save the file.
2022-08-21 16:37:20 +02:00
Please read about adding or updating a language in \href{https://github.com/msberends/AMR/wiki/}{our Wiki}.
\subsection{Changing the Default Language}{
2019-05-10 16:44:59 +02:00
2022-08-27 20:49:37 +02:00
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("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:
2020-09-14 12:21:23 +02:00
\enumerate{
\item Setting the \link[=AMR-options]{package option} \code{\link[=AMR-options]{AMR_locale}}, either by using e.g. \code{set_AMR_locale("German")} or by running e.g. \code{options(AMR_locale = "German")}.
2022-08-19 12:33:14 +02:00
2022-10-05 09:12:22 +02:00
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.
2022-08-19 12:33:14 +02:00
\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.
2020-09-14 12:21:23 +02:00
}
Thus, if the \link[=AMR-options]{package option} \code{\link[=AMR-options]{AMR_locale}} is set, the system variables \code{LANGUAGE} and \code{LANG} will be ignored.
2020-09-14 12:21:23 +02:00
}
2019-05-10 16:44:59 +02:00
}
\examples{
2022-08-20 20:17:14 +02:00
# Current settings (based on system language)
2022-08-19 12:33:14 +02:00
ab_name("Ciprofloxacin")
2022-10-05 09:12:22 +02:00
mo_name("Coagulase-negative Staphylococcus (CoNS)")
2019-05-10 16:44:59 +02:00
2022-08-19 12:33:14 +02:00
# setting another language
2022-10-05 09:12:22 +02:00
set_AMR_locale("Spanish")
ab_name("Ciprofloxacin")
mo_name("Coagulase-negative Staphylococcus (CoNS)")
# setting yet another language
2022-08-19 12:33:14 +02:00
set_AMR_locale("Greek")
ab_name("Ciprofloxacin")
2022-10-05 09:12:22 +02:00
mo_name("Coagulase-negative Staphylococcus (CoNS)")
2019-05-10 16:44:59 +02:00
2022-10-05 09:12:22 +02:00
# setting yet another language
set_AMR_locale("Ukrainian")
2022-08-19 12:33:14 +02:00
ab_name("Ciprofloxacin")
2022-10-05 09:12:22 +02:00
mo_name("Coagulase-negative Staphylococcus (CoNS)")
2021-09-29 12:12:35 +02:00
2022-08-20 20:17:14 +02:00
# set_AMR_locale() understands endonyms, English exonyms, and ISO-639-1:
set_AMR_locale("Deutsch")
set_AMR_locale("German")
set_AMR_locale("de")
2022-12-10 10:09:57 +01:00
ab_name("amox/clav")
2022-08-20 20:17:14 +02:00
# reset to system default
2022-08-19 12:33:14 +02:00
reset_AMR_locale()
2022-12-10 10:09:57 +01:00
ab_name("amox/clav")
2019-05-10 16:44:59 +02:00
}