
R/translate.R
translate.RdTranslate a message given a set of known messages and regex patterns
translate(
msg,
dictionary,
domain = "R-svAssert",
trim = TRUE,
format = TRUE,
...
)
format_inline_(
...,
.envir = parent.frame(),
collapse = TRUE,
keep_whitespace = TRUE,
post_translate = TRUE
)
create_messages_script(
dictionary,
topic,
pkg_dir = ".",
export = TRUE,
source = NULL,
release = NULL
)The message to be translated
A character vector with messages to translate and regular expressions to find the corresponding error strings as names.
The domain where to look for messages (see gettext()). The
default looks in "R-svAssert", and it should be changed for translations
that are available in another package.
Logical, indicating whether leading and trailing whitespace
before looking for message translation. TRUE by default.
Logical, indicating whether to format the translated message
with format_inline_(). Default is TRUE.
Messages passed to format_inline().
The environment in which to evaluate expressions in ....
Logical, indicating whether to collapse multiple lines into a single string with newlines.
Logical, indicating whether to keep whitespace in the formatted message.
Logical, indicating whether to translate ", and " and ", or " in the final message.
The identifier for a dictionary. Usually, it should be the name
of the package that generates the messages, but it is not mandatory. Use
"general" for a set with no particular topic.
The root directory of the sources of an R package. The
produced messages-topic.R script file is created in the R/
subdirectory.
Logical, indicating whether the created object should be
exported. Default is TRUE.
An optional URL indicating where the messages come from, e.g., a GitHub repository.
An optional string indicating the release version of the source where the messages were extracted from.
For translate() the translated message if a correspondence is
found in the dictionary and a translation is known, or the original
message otherwise.
For format_inline_() a formatted message as a string. If an error
occurs during formatting, a warning is issued and a simple concatenation of
the arguments is returned instead.
For create_messages_script() the name of the script file that is
created is returned invisibly. The function is used for its side effect of
creating the adequate script file.
checkmate_msgs[1:3] # First 3 {checkmate} messages
#> ^Variable '([^']*)': (.+)$
#> "Variable {.var %s}: %s."
#> ^Unknown type '([^']*)' to specify check for names\\. Supported are 'unnamed', 'named', 'unique' and 'strict'\\.$
#> "Unknown option '%s' to specify check for names. Supported are 'unnamed', 'named', 'unique' and 'strict'."
#> ^Unknown class identifier '([^']*)'$
#> "Unknown class identifier {.cls %s}."
msg <- "Unknown class identifier 'my_class'"
translate(msg, checkmate_msgs, domain = "R-svAssert")
#> [1] "Unknown class identifier 'my_class'"