[R] gettext weirdness

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Feb 4 09:27:29 CET 2013


The 'wierdness' is that 'R' is a domain of C messages and you are 
trying to use it from R.  How messages are massaged before being sent 
for translation depends on the language, including how trailing spaces 
are handled.   There is no reason to expect domains intended for C 
code to work in R-level gettext(), nor in stop() etc.

This was really an R-devel question: see the posting guide.

On Mon, 4 Feb 2013, Florent Angly wrote:

> Hi,
>
> I am trying to use the gettext() function to translate some text. I have 
> never used this function before, so, it's entirely possible that I am doing 
> something wrong. The issue that I am encountering is that gettext() properly 
> translates some text, but not some other.
>
> Natural language was compiled in my R (installed from the Debian 
> repositories):
> $ R
> R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
> [...]
>  Natural language support but running in an English locale
> [...]
>> q()
>
> Here is some text that has some translation in the file ./po/fr.po:
>    #: src/main/errors.c:290
>    msgid "invalid option \"warning.expression\""
>    msgstr "option incorrecte \"warning.expression\""
>    [...]
>    #: src/main/errors.c:582
>    msgid "Error in "
>    msgstr "Erreur dans "
>
> Start R in French and see if I can get something translated to French:
> $ LANG=fr_FR.UTF8  R
>> stop('This is an error')
> Erreur : This is an error
>
>> bindtextdomain("R") # does not seem necessary, but just to be safe...
> [1] "/usr/share/R/share/locale"
>
>> gettext("Error in ", domain="R")
> [1] "Error in "
>
>> "invalid option \"warning.expression\"" -> msg; gettext(msg, domain="R")
> [1] "option incorrecte \"warning.expression\""
>
>
> So, the stop() function successfully translates. I can also manually 
> translate some entries, but why can does it not work for gettext("Error in ", 
> domain="R")?
> Any idea?
> Thanks
>
> Florent
>
> ______________________________________________
> R-help at r-project.org 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list