ngettext
is used to provide
a choice of messages depending on the value of an integer.
gettext(..., domain=NULL) ngettext(n, msg1, msg2, domain=NULL)
msg1
or
msg2
.
n=1
.
n
is not set to 1.
gettext
returns a single character vector
containing all values in the input
...
coerced to
character.
If translation was enabled, they would be translated according to the given domain.
ngettext
returns a character string, either
msg1
or
msg2
depending
upon the value of
n
.
These functions were added to emulate R functions,
gettext
and
ngettext
,
but Native Language Support and support for domains are not included in this version
of S-PLUS, so these functions have limited functionality.
# Select the correct warning message func1 <- function(x, y, z) { miss <- c("x", "y", "z")[c(missing(x), missing(y), missing(z))] if(length(miss) > 0) { warning(sprintf(ngettext(length(miss), "Variable %s is missing.\n", "Variables %s are missing.\n"), paste(sQuote(miss), collapse = ", "))) } } func1(y=5) func1(y=5,z=2)