From ripley at stats.ox.ac.uk  Mon Feb  4 15:02:25 2013
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 04 Feb 2013 14:02:25 +0000
Subject: [Rd] [R] gettext weirdness
In-Reply-To: <510F9821.40406@gmail.com>
References: <510F601E.8030805@gmail.com>
	<alpine.LFD.2.03.1302040823330.21486@stats.ox.ac.uk>
	<510F9821.40406@gmail.com>
Message-ID: <510FBF71.4060400@stats.ox.ac.uk>

On 04/02/2013 11:14, Florent Angly wrote:
> Hi Brian,
>
> I appreciate your clarifications. I am sending this reply to the
> R-devel, as per you suggestion.
>
> As mentioned in my post, I have no prior experience with this R function
> and logically, I looked up its help page, which states:
>> Conventionally the domain for *R* warning/error messages in package
>> pkg is |"R-pkg"|, and that for C-level messages is |"pkg"|.
> While it certainly mentions messages in the C-realm, it does not state
> that they cannot be translated using gettext(). This is less than
> obvious and could perhaps be explicitly stated.

You are asking us to state what *can not* be done?  It does clearly 
state the the domain for *R* messages in a package is "R-pkg".   Domain 
"R" is not of that form.

> If gettext() cannot be used to get the translation for the "Error in "
> message in some supported language, then is there an alternative?

You put it in a domain named "R-pkg", prepared using xgetttext().

>
> Best,
>
> Florent
>
>
>
> On 04/02/13 18:27, Prof Brian Ripley wrote:
>> 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.
>>>
>>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
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



[Rd] [R] gettext weirdness
Prof Brian Ripley