[Rd] suppress *specific* warnings?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Oct 26 14:20:18 CEST 2012
On 26/10/2012 12:04, peter dalgaard wrote:
>
> On Oct 26, 2012, at 11:17 , Martin Maechler wrote:
>
>>>>>>> Duncan Murdoch <murdoch.duncan at gmail.com>
>>>>>>> on Thu, 25 Oct 2012 06:51:25 -0400 writes:
>>
>>> On 12-10-25 5:28 AM, Martin Maechler wrote:
>>>> Sorry guys, for coming late,
>>>> but *please* don't go there.
>>>>
>>>> I've been there years ago,
>>>> and found later why the approach is flawed "by design" :
>>>>
>>>> Internationalization / Localization:
>>>>
>>>> - If the warning comes from a "standard R" function,
>>>> the warning is almost surely different in a (say) German
>>>> locale, and your pattern won't be detected.
>>>>
>>>> - Ditto if from a recommended package.
>>>>
>>>> - If it is a warning that is not translated then it may be that
>>>> it is just not *YET* translated.
>>
>>> I think the other Martin's suggestion addressed this: he matched the
>>> translated message, not the English original.
>>
>>> Duncan Murdoch
>>
>> Well, I don't think I understand.
>> Of course you can only match "the message" that warning() or
>> error() {or rather tryCatch() ,...} produces.
>> But you cannot guarantee nor know (for sure) if that message is 'original'
>> or translated.
>> "cannot", because AFAIK
>> we cannot guarantee Sys.setlocale() is obeyed platform
>> independently:
>> You would have to query the current and save that, set it to C, get the
>> message, and then reset the locale to the previously saved one.
>> And these do not work reliably, on some platforms, AFAIK and
>> read our documentation.
>
> I think the point was to use gettext() on the pattern-to-match. If
> the warning is translated, so would this be. The main limitations would seem
to be that you have to be d*mn sure to get the spelling right and,
presumably, it only works with straight string translations, not variant
forms like
>
> msgid "found %d fatal error"
> msgid_plural "found %d fatal errors"
> msgstr[0] "s'ha trobat %d error fatal"
> msgstr[1] "s'han trobat %d errors fatals"
Yes: you also need to get the domain right (and it would be unsafe not
to specify it on the gettext() call). And C-level messages do move
between domains; for example between R 2.15.x and R-devel most of the
graphics ones have moved from 'R' to 'graphics'.
--
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-devel
mailing list