Learn R Programming

msgtools (version 0.2.4)

templates: Handle message templates (.pot files)

Description

Read, write, and generate .pot diagnostic message templates

Usage

make_template(charset = "UTF-8", pkg = ".", domain = "R")
read_template(pkg = ".", domain = "R")
write_template(template, pkg = ".", verbose = getOption("verbose"))
template_exists(pkg = ".", domain = "R")
sync_template(charset = "UTF-8", pkg = ".", domain = "R", verbose = getOption("verbose"))
template_current(template, pkg = ".", domain = "R")

Arguments

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 as.package.
domain
A character string specifying the “domain” of the messages. Either “R” (the default) or “C”. This is case insensitive.
template
An object of class “po” containing a message translation template.
verbose
A logical. Should the function be chatty?

Value

make_template and read_template reutrn an R6 object of class “po”. write_template returns the path to the file, invisibly.

Details

read_template and write_template provide basic input and output functionality for translation template (.pot) files. If called from with an R package directory, the locations of these fies are identified automatically.

make_template generates a new template in memory, without writing it to disk. sync_template makes a new template and writes it to disk or, if a template file already exists, overwrites it.

sync_template() updates the template file. sync_translations further updates translation files against that template.

See Also

get_messages to read messages into memory without creating a template file, use_localization to setup a package for localization (including generation of a template file)

Examples

Run this code
pkg <- dummy_pkg()

# check for existing template
try(template_exists(pkg = pkg))

# generate an in-memory template
pot <- make_template(pkg = pkg)
write_template(pot, pkg = pkg)
  

Run the code above in your browser using DataLab