Im wondering whether anyone can help me with a translation exercise. I have a
package named oce, which does oceanographic processing, and Id like to make
it produce graphs with labels that work in different languages. For example,
in English I write Depth and in Spanish Id like to write Profundidad.
In my po directory I have R-oce.pot and es.po. As a first step, Ive
translated just the phrases Depth (m) and Depth [m]. Then I build and
installed my package. Within R,
library(oce)
bindtextdomain("R-oce)
yields
[1] "/Library/Frameworks/R.framework/Versions/3.0/Resources/library/oce/po
and then, in the OSX shell,
msgunfmt
/Library/Frameworks/R.framework/Versions/3.0/Resources/library/oce/po/es/LC_MESSAGES/R-oce.mo
| grep -1 Depth
yields
msgid "Depth (m)"
msgstr "Profundidad (m)"
--
--
msgid "Depth [m]"
msgstr "Profundidad [m]
so it seems that I have successfully installed the translations. Then, I run R
from the shell with
LC_MESSAGES=es_ES.UTF-8 R --no-save < spanish.R
where spanish.R consists of
library(oce)
cat(gettext("Depth (m)"), "\n")
and I get
...
R es un software libre y viene sin GARANTIA ALGUNA.
...
(i.e. a Spanish introduction paragraph from R) which suggests that my
env-variable is OK, followed by
> library(oce)
Loading required package: mapproj
Loading required package: maps
> cat(gettext("Depth (m)"), "\n")
Depth (m)
which, obviously, has not translated the text. A similar test with
LANG=es_ES.UTF-8 R --no-save < spanish.R
yields the same results.
All of this is with R 3.0.2 on an Apple OSX platform (Mavericks); session info
is below.
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] oce_0.9-14 mapproj_1.2-1 maps_2.3-2
QUESTION: any hints on how I can get the translations to be passed through
gettext()?
Thanks!
Dan E. Kelley, Professor and Graduate Coordinator
Oceanography Department, Dalhousie University
PO BOX 15000
Halifax, NS B3H 4R2
phone:(902)494-1694 fax:(
)-3877 [email protected]<mailto:[email protected]>
http://oceanography.dal.ca/person/Kelley_Dan.html
http://graduatecoordinator.oceanography.dal.ca/
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.