check_cracked_messages {potools}R Documentation

Check for cracked messages more suitable for templating

Description

Diagnose the R messages in a package to discover the presence of "cracked" messages better served for translation by templating. See Details.

Usage

check_cracked_messages(message_data)

Arguments

message_data

A data.table, or object convertible to one.

Details

Error messages built like stop("You gave ", n, " arguments, but ", m, " are needed.") are in general hard for translators – the correct translation may be in a totally different order (e.g., this is often the case for Japanese). It is preferable instead to use base::gettextf() to build a templated message like stop(gettextf("You gave %d arguments but %d are needed.", n, m)). Translators are then free to rearrange the template to put the numeric pattern where it fits most naturally in the target language.

Value

A data.table with columns call, file, line_number, and replacement summarizing the results.

Author(s)

Michael Chirico

See Also

translate_package(), update_pkg_po()

Examples


pkg <- file.path(system.file(package = 'potools'), 'pkg')
# copy to a temporary location to be able to read/write/update below
tmp_pkg <- file.path(tempdir(), "pkg")
dir.create(tmp_pkg)
file.copy(pkg, dirname(tmp_pkg), recursive = TRUE)

# first, extract message data
message_data = get_message_data(tmp_pkg)

# now, diagnose the messages for any "cracked" ones
check_cracked_messages(message_data)

# cleanup
unlink(tmp_pkg, recursive = TRUE)
rm(pkg, tmp_pkg, message_data)

[Package potools version 0.2.4 Index]