tools (version 3.3)

update_pkg_po: Prepare Translations for a Package

Description

Prepare the po directory of a package and compile and install the translations.

Usage

update_pkg_po(pkgdir, pkg = NULL, version = NULL, copyright, bugs)

Arguments

pkgdir
The path to the package directory.
pkg
The package name: if NULL it is read from the package's DESCRIPTION file.
version
The package version: if NULL it is read from the package's DESCRIPTION file.
copyright, bugs
optional character strings for the Copyright and Report-Msgid-Bugs-To details in the template files.

System requirements

This function requires the following tools from the GNU gettext-tools: xgettext, msgmerge, msgfmt, msginit and msgconv. These are part of most Linux distributions and easily compiled from the sources on Unix-alikes (including OS X). Pre-compiled versions for Windows are available in https://www.stats.ox.ac.uk/pub/Rtools/goodies/gettext-tools.zip.

It will probably not work correctly for en@quot translations except in a UTF-8 locale, so these are skipped elsewhere.

Details

This performs a series of steps to prepare or update messages in the package.
  • If the package sources do not already have apodirectory, one is created.
  • xgettext2potis called to create/update a filepo/R-pkgname.potcontaining the translatable messages in the package.
  • All existing files in directorypowith namesR-lang.poare updated fromR-pkgname.pot,checkPoFileis called on the updated file, and if there are no problems the file is compiled and installed underinst/po.
  • In a UTF-8 locale, atranslationR-en@quot.pois created with UTF-8 directional quotes, compiled and installed underinst/po.
  • The remaining steps are done only if filepo/pkgname.potalready exists. Thesrc/*.{c,cc,cpp,m,mm}files in the package are examined to create a filepo/pkgname.potcontaining the translatable messages in the C/C++ files. If there is asrc/windowsdirectory, files within it are also examined.
  • All existing files in directorypowith nameslang.poare updated frompkgname.pot,checkPoFileis called on the updated file, and if there are no problems the file is compiled and installed underinst/po.
  • In a UTF-8 locale, atranslationen@quot.pois created with UTF-8 directional quotes, compiled and installed underinst/po.

Note that C/C++ messages are not automatically prepared for translation as they need to be explicitly marked for translation in the source files. Once that has been done, create an empty file po/pkgname.pot in the package sources and run this function again.

pkg = "base" is special (and for use by Rdevelopers only): the C files are not in the package directory but in the main sources.

See Also

xgettext2pot.