Extracting translatable text

The R implementation code is never modified by the translators. Translation is accomplished by extracting the translatable text from the code files and then creating separate files containing the translated text, one file for each language. The R gettext, ngettext, and gettextf functions use compiled versions of these files.

You can use the R xgettext2pot function to extract strings marked as translatable (i.e., strings wrapped in the gettext, ngettext, or gettextf functions) and save them to a .pot (po template) file. The .pot file should have the same name as the domain specified in the bindtextdomain function. If you are localizing output from an extension command implemented in R, then the .pot file should have the same name as the extension command, in upper case, and with any spaces replaced with underscores--for example, MYORG_MYSTAT.pot for an extension command named MYORG MYSTAT.

In the .pot file:

  • Change the charset value, in the msgstr field corresponding to msgid "", to utf-8.
  • A pot file includes one msgid field with the value "", with an associated msgstr field containing metadata. There must be only one of these.
  • Optionally, update the generated title and organization comments.