Skip to content
Prev 5029 / 12125 Next

[R-pkg-devel] translation .mo files

Dear Paul,

Here's some information that I prepared for translators of the Rcmdr package, slightly edited to make it more generic. Perhaps you'll find it useful:

R provides a general facility for translating messages from English to other languages using the GNU gettext translation tools <http://www.gnu.org/software/gettext/>. These tools are used both for R itself and for R packages, though most packages are not set up to allow translation.

How translation works in R is described in a 2005 article in R News, available at <https://cran.r-project.org/doc/Rnews/Rnews_2005-1.pdf>. There is also some information in the R manuals, at <https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Internationalization>, <https://cran.r-project.org/doc/manuals/R-admin.html#Localization-of-messages>, and at <http://developer.r-project.org/Translations30.html>.

The general procedure for preparing translations is very simple. I'll explain it briefly in case you're unfamiliar with it. The package sources include the plain-text file <package-name>.pot in the package po subdirectory. You would copy this file to R-xx.po (where xx is the usually two-character code for your language -- e.g., fr for French, thus R-fr.po) and then edit that file to provide translations of the Rcmdr messages. (In your case, you could work backwards from the .po file you received to make a .pot file.) 

You would then use the GNU gettext tools (available at <https://www.gnu.org/software/gettext/>) to compile your .po file into a .mo file, conventionally named R-<package-name>.mo. The .mo file would be placed in the package sources at inst/po/xx/LC_MESSAGES/ . You would then test your translation by building and installing the package. 

I hope this helps,
 John

  -----------------------------
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox
Message-ID: <950AF541-C0DA-4A00-82CB-2CAFE374029C@mcmaster.ca>
In-Reply-To: <25768_1581149714_0188FDtn012660_053184fa-8caa-e09a-603f-9bd37cc2362c@gmail.com>