msgtools-package: Tools for developing diagnostic messages

Description Usage Arguments Details Note Author(s) References See Also Examples

Description

This package implements a number utilities for developing and maintaining error, warning, and other diagnostic messages in R packages, including checking for consistency across messages, spell-checking messages, and managing internationalization and location of messages (i.e., translations into various languages).

Usage

1
2
use_localization(charset = "UTF-8", pkg = ".", domain = "R",
  verbose = getOption("verbose"))

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.

verbose

A logical. Should the function be chatty?

Details

use_localization (alias: use_l10n) is the high-level, devtools-style function to create a /po directory and initialize a translation template (.pot) file.

make_template provides a lower-level interface for this internationalization step and make_translation handles localization. install_translations installs the translations for use.

get_messages returns a tibble (data frame) of messages and their file locations. spell_check_msgs returns a subset of messages with possible misspelled words and suggested replacements.

Note

Most of the functionality of this package requires gettext. Use check_for_gettext to see if it is available on your system; a Windows installer is provided in install_gettext.

Author(s)

Thomas J. Leeper

References

GNU gettext Manual

See Also

make_template, make_translation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
  # create example package
  pkg <- dummy_pkg()
  
  # get messages in memory
  get_messages(pkg = pkg)
  # spell check messages
  spell_check_msgs(pkg = pkg)

  # setup pkg for localization
  use_localization(pkg = pkg)
  
  # make a translation
  tran <- make_translation("es", translator = "Some Person <example@examle.com>", pkg = pkg)
  write_translation(tran, pkg = pkg)

  # install translation(s)
  check_translations(pkg = pkg) # check for errors before install
  install_translations(pkg = pkg)

RL10N/msgtools documentation built on May 8, 2019, 5:56 a.m.