Description Usage Arguments Details Note Author(s) References See Also Examples
This package implements a number utilities for developing and maintaining error, warning, and other diagnostic messages in R packages, including checking for consistency across messages, spell-checking messages, and managing internationalization and location of messages (i.e., translations into various languages).
1 2 | use_localization(charset = "UTF-8", pkg = ".", domain = "R",
verbose = getOption("verbose"))
|
charset |
A character string specifying the character set of the translation template file. |
pkg |
The directory of an R package to extract diagnostic messages from. Path is passed to |
domain |
A character string specifying the “domain” of the messages. Either “R” (the default) or “C”. This is case insensitive. |
verbose |
A logical. Should the function be chatty? |
use_localization
(alias: use_l10n
) is the high-level, devtools-style function to create a /po directory and initialize a translation template (.pot) file.
make_template
provides a lower-level interface for this internationalization step and make_translation
handles localization. install_translations
installs the translations for use.
get_messages
returns a tibble (data frame) of messages and their file locations. spell_check_msgs
returns a subset of messages with possible misspelled words and suggested replacements.
Most of the functionality of this package requires gettext. Use check_for_gettext
to see if it is available on your system; a Windows installer is provided in install_gettext
.
Thomas J. Leeper
make_template
, make_translation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # create example package
pkg <- dummy_pkg()
# get messages in memory
get_messages(pkg = pkg)
# spell check messages
spell_check_msgs(pkg = pkg)
# setup pkg for localization
use_localization(pkg = pkg)
# make a translation
tran <- make_translation("es", translator = "Some Person <example@examle.com>", pkg = pkg)
write_translation(tran, pkg = pkg)
# install translation(s)
check_translations(pkg = pkg) # check for errors before install
install_translations(pkg = pkg)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.