templates: Handle message templates (.pot files)

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Read, write, and generate .pot diagnostic message templates

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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?

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.

Value

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

Author(s)

Thomas J. Leeper

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

1
2
3
4
5
6
7
8
9
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)
  

msgtools documentation built on May 30, 2017, 5:12 a.m.