gettext
Translate Text Messages

Description

Translates character vectors into other languages. (This functionality is supported only when Native Language Support is enabled in the build of R.) The function ngettext is used to provide a choice of messages, depending on the value of an integer.

Usage

gettext(..., domain = NULL)
ngettext(n, msg1, msg2, domain = NULL)

Arguments

n an integer value used to select msg1 or msg2.
msg1 a character string to use if n=1.
msg2 a character string to use if n is not set to 1.
... one or more character vectors.
domain the domain to use for language translation.

Details

These functions emulate the R functions gettext and ngettext, but Native Language Support and support for domains are not included in this version, so these functions have limited functionality.
Value

gettextreturns a single character vector containing all values in the input ... coerced to character. If translation is enabled, they are translated according to the given domain.
ngettextreturns a character string: either msg1 or msg2, depending on the value of n.
See Also
gettextf, sprintf.
Examples
# 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)
Package base version 6.0.0-69
Package Index