Find likely translation errors using static source code analysis.
We look into a series of R source files and identify all calls to
t_
and examine the key and interpolation data used within
these calls.
lint_translations(path, obj, language = NULL, root = NULL, title = NULL)
lint_translations_package(root, language = NULL)
Path to the translations to test. This can be a
character vector of file names and directory names - directory
names are expanded (non-recursively) to find all .R
files.
A translator object, or `NULL`. If `NULL`, then the report will indicate only strings that might be translated vs bare strings, rather than check the likely success of translation.
Optional language to use as the language to lint. Each language must be at present linted separately
A root directory, below which the files in path
will be treated relatively (e.g., pass a package's root
directory here, and then set path = "R"
). Using this
shortens the reported filenames considerably
An optional title that will be used in reporting
A lint_translations
object, which can be passed
through to lint_translations_report
This will expand in future and is currently quite limited.
Currently, only calls to t_()
are inspected - not calls to
$t()
in a translator object, not calls to $replace
etc. The package
and name
arguments to t_()
are also currently ignored, which will lead to spurious errors. A
version of this that automatically works for packages will also be
written. The key and interpolation data must (currently) be
literals - you cannot save the key or data as a variable and pass
that by variable name.
The function lint_translations_package
is a wrapper around
lint_translations
to make working with a package a bit
easier. It's a bit flakey at the moment because the translator
will be loaded from the currently installed package, but the usage
will be checked in the source tree. This will be addressed in a
future version (see reside-90)