Jika Dukungan Bahasa Asli diaktifkan di versi R ini, coba terjemahkan vektor karakter atau atur di mana terjemahan dapat ditemukan.
gettext(…, domain = NULL)<p></p><p>ngettext(n, msg1, msg2, domain = NULL)</p><p>bindtextdomain(domain, dirname = NULL)</p>
| Parameter | Deskripsi |
|---|---|
… |
One or more character vectors. |
domain |
The ‘domain’ for the translation. |
n |
a non-negative integer. |
msg1 |
the message to be used in English for n = 1. |
msg2 |
the message to be used in English for n = 0, 2, 3, …. |
dirname |
The directory in which to find translated message catalogs for the domain. |
# NOT RUN {
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] ""
# }
# NOT RUN {
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 = ", ")))
# }