bindtextdomain("R") # non-null if and only if NLS is enabled
for(n in 0:3)
print(sprintf(ngettext(n, "%d variable has missing values",
"%d variables have missing values"),
n))
## Not run: ------------------------------------
# ## for translation, those strings should appear in R-pkg.pot as
# msgid "%d variable has missing values"
# msgid_plural "%d variables have missing values"
# msgstr[0] ""
# msgstr[1] ""
## ---------------------------------------------
miss <- c("one", "or", "another")
cat(ngettext(length(miss), "variable", "variables"),
paste(sQuote(miss), collapse = ", "),
ngettext(length(miss), "contains", "contain"), "missing values\n")
## better for translators would be to use
cat(sprintf(ngettext(length(miss),
"variable %s contains missing values\n",
"variables %s contain missing values\n"),
paste(sQuote(miss), collapse = ", ")))
Run the code above in your browser using DataLab