From p.dalgaard at biostat.ku.dk  Sat May 21 21:33:13 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Sat May 21 21:33:18 2005
Subject: [Rd] Internationalizing the Rcmdr package?
In-Reply-To: <20050521173712.ZFMI25800.tomts13-srv.bellnexxia.net@JohnDesktop8300>
References: <20050521173712.ZFMI25800.tomts13-srv.bellnexxia.net@JohnDesktop8300>
Message-ID: <x2u0kwidc6.fsf@turmalin.kubism.ku.dk>

"John Fox" <jfox@mcmaster.ca> writes:

> Dear R-devel list members,
> 
> I'm considering adding support for other languages than English to the Rcmdr
> package. I understand that the use of Tcl/Tk by the Rcmdr package means I
> won't be able to make full use of the internationalization facilities in R
> 2.1.0. I'm interested, therefore, in whether the following, more limited,
> strategy (which bears some similarity to the internationalization facilities
> in R) seems reasonable or whether there's a better approach. As well, I'm
> interested in whether the proposed approach is sufficiently flexible to be
> worthwhile -- does it cover enough languages?
> 
> It would be simple for me to provide a file of messages, labels, and other
> text used by the Rcmdr, organizing this file with one message per line. A
> copy of the file, named, e.g., messages.francais, could contain translations
> into another language (e.g, French). Setting
> options(Rcmdr=list(language=francais)) would then activate translation when
> the Rcmdr starts up, reading the messages file into a data frame, treating
> the English text as row names. The messages could be handled by a function,
> say Text(), which would return English or translated text, as appropriate.
> Some experimentation shows that message retrieval by this scheme is
> essentially instantaneous even when there are several thousand relatively
> long messages in the data frame. 

Offhand, I think you're better off latching on to an existing
mechanism. Tcl has something known as "msgcat", which appears to be
similar to GNU gettext (and there are conversion tools), or perhaps
you could interface to gettext itself (we do have the gettext()
function at the R level).

Two tricky bits: 

(A) shortcut keys, which need to be coordinated to menu items
    ("Accept/Break/Cancel" translates to "Accepter/Afbryd/Annuller" in
    Danish - if you're a little malicious, anyway)

(B) What is the general mechanism for extending message catalogs by an
    R package?

Brian may well have thought of this stuff already.


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Internationalizing the Rcmdr package?
Peter Dalgaard