Dictionaries allow psychTestR tests to
support multiple languages during test administration.
These dictionaries (class name:
define mappings between string keys (e.g.
and (potentially) multiple outputs,
each corresponding to different languages (e.g. English, German).
The dictionary is passed as an argument to
and provides the context for the evaluation of calls to
i18n, responsible for translating individual terms.
i18n_dict$new(x, markdown) defines and returns a new dictionary
which can be saved as an object.
Its first argument,
x, should be a data frame defining the dictionary.
Each row of this data frame should correspond to a term to be translated.
It should have a column entitled 'key', which defines the identifying
keys for each term.
All other columns should provide translations into different languages,
with the language being identified by the column name,
according to ISO 639-2 conventions (lower-case, e.g. 'en').
The second argument,
markdown, is a scalar Boolean (default =
that determines whether the data frame is formatted in
Markdown or not (Markdown allows for efficient and readable
text markup, e.g. italic and bold).
Text is parsed according to standard Markdown conventions,
with one addition: two successive backslashes
(written "\" in a text file, or "\\" in R)
are interpreted as a new paragraph.
x is a dictionary object,
converts the dictionary back to a data frame representation.
x$edit(key, language, new),
edits a given entry in the dictionary for a given
replacing it with the value
See the vignette "Editing dictionaries" for details.
x$translate(key, language, allow_missing)
uses the dictionary
NULL is returned
when no translation is found, otherwise an error is thrown.
i18n_dict$new(x, markdown = TRUE)