Hello Philippe, I see now that I was being naive in assuming that resetting language settings in Windows would do anything to the buttons - they of course sell multilanguage support nowadays, and I seem to have a one-language-only version.
I think that I can live with option 1). If users understand their Windows buttons, they will also understand the R buttons, and I can use my time better than spending it on 2) and 3). (Of course, users of Rcmdr will appreciate that buttons and messages match!) Regarding msgcat vs. R-internal, I only resorted to msgcat because I found it easier to find out how to use it. I think I will replace the ilab function in my toy example by a gettext version as soon as I find out how to do that (I suppose I can take that from the .onLoad function in Rcmdr). However, I cannot check that it works before I have packaged my package, can I ? That's a disadvantage of the R-internal approach vs. the msgcat approach at the stage I am currently in. By the way, do you know why tcltk2 causes the two commands below to stop functioning? tcl("::msgcat::mcload","C:/testdirectory") ilab <- function(lab) tclvalue(tcl("namespace","eval","::tcl::minidummy","::msgcat::mc",.Tcl.args(lab))) Regards, Ulrike Philippe Grosjean wrote: > > Hello Ulrike, > > I think that the reason why default buttons are not translated is > because they are managed by Windows. You have no control on their text. > Running on a Windows in English, you got those buttons in English, > Windows in German -> buttons in German, etc... > So, three options from there: > > 1) You just assume that the end-users want the GUI in the same language > as Windows,... or accept to have default buttons in Window's language if > they switch to another internationalisation, > > 2) Do the same as in R commander: rewrite the dialog boxes so that they > don't use default Windows buttons (almost impossible for file > open/close, dir choose, etc. dialog boxes)! > > 3) Use AutoIt or AutoHotKey to change the default buttons messages (with > lots of sweat, you can compile a satellite program to do so),... or with > even more time and effort, compile a C function in R that calls the > right API to change default buttons' messages in your dialog boxes. > > Sorry that I cannot give you a better solution... > > Oh yes, regarding translation of Tcl/Tk messages from within R, I really > believe that translating these messages using the R mechanism instead of > msgcat in Tcl is much better. That way, you centralize all translations > (R functions and GUI elements) in a single translation file. It is the > approach used by R Commander, by the way. So, you got inspiration from > there for your own code. > Best, > > Philippe > ..............................................<°}))><........ > ) ) ) ) ) > ( ( ( ( ( Prof. Philippe Grosjean > ) ) ) ) ) > ( ( ( ( ( Numerical Ecology of Aquatic Systems > ) ) ) ) ) Mons-Hainaut University, Belgium > ( ( ( ( ( > .............................................................. > > Ulrike Groemping wrote: >> Dear R-SIG-GUIs, >> >> documentation of getLanguage / setLanguage in tcltk2 pointed me towards >> the >> msgcat package in Tcl/Tk, and I used it for internationalizing my GUI >> entries - trying to avoid having to write individual tools like >> RcmdrTkmessagebox etc. I am an absolute Tcl/Tk beginner and still looking >> for the final strategy to do a larger GUI project in, currently working >> on >> Windows with R 2.8.0 or R 2.7.1 (behave identical). And one important >> aspect >> is internationalization. >> >> I have now managed to program my draft and not yet functional GUI in >> English >> and show it in German by using an msg file with msgcat. On my computer, >> everything shows well in German. Then I got the idea that it would be >> nice >> to show an msgcat example in the help for getLanguage/setLanguage, and I >> prepared a toy example for sending to Philippe (cf. below). However, >> while >> changing the language does change most messages, it does not work with >> built-in buttons - these remain German on my machine, even if I restart >> my >> computer after changing system settings for all language aspects I could >> find on my computer from German to English. >> >> I remember having read something like that from John, when he started >> internationalizing Rcmdr, but I had thought it would be long solved by >> now. >> Since internationalization appears to work at installation time >> (otherwise >> my buttons wouldn't be in German), and since there are many tcltk message >> files in the Tcl directory, it looks to me - as a possibly rather naive >> tcltk novice - that one would just have to find a way to reset some >> environment variable or otherwise direct tcltk to look in the right >> places. >> >> Any thoughts on that ? >> >> Regards, Ulrike >> >> ####### the toy example follows >> require(tcltk) >> ### the following two lines must be executed BEFORE loading tcltk2 >> ### otherwise they do not work !!! >> tcl("::msgcat::mcload","C:/testdirectory") >> ilab <- function(lab) >> tclvalue(tcl("namespace","eval","::tcl::minidummy","::msgcat::mc",.Tcl.args(lab))) >> >> ## mini example of German tcl message file >> ## has to be saved under name de.msg >> ## in the testdirectory given above >> ## without the comment character in lines below >> ## (it is important to avoid line breaks within individual mset entries) >> #namespace eval ::tcl::minidummy { >> # ::msgcat::mcset de "If you choose Yes, all unsaved inputs will be >> lost." >> "Wenn Sie Ja wählen, gehen alle noch nicht gespeicherten Eingaben >> verloren." >> # ::msgcat::mcset de "Really Exit WITHOUT Save ?" "Wirklich OHNE >> Speichern Beenden ?" >> # ::msgcat::mcset de "Yes pressed" "Ja gedrückt" >> # ::msgcat::mcset de "No pressed" "Nein gedrückt" >> #} >> >> imsgboxtest <- function(){ >> td <- tclvalue(tkmessageBox(message=ilab("If you choose Yes, all unsaved >> inputs will be lost."), >> title=ilab("Really Exit WITHOUT Save >> ?"),type="yesno",default="yes",icon="question")) >> if (td == "yes") cat(paste(ilab("Yes pressed"),"\n")) else >> cat(paste(ilab("No pressed"),"\n")) >> } >> imsgboxtest() >> >> require(tcltk2) ## ruins functionality of the load and function >> definition >> above >> ## if loaded too early! >> oldlang <- getLanguage() >> if (oldlang != "") { >> # Switch to English and test a command that issues a warning >> if (setLanguage("en_US")) imsgboxtest() >> # Switch to French and test a command that issues a warning >> if (setLanguage("fr_FR")) imsgboxtest() >> # Switch to German and test a command that issues a warning >> if (setLanguage("de_DE")) imsgboxtest() >> # Restore previous language >> setLanguage(oldlang) >> } >> > > > -- > ..............................................<°}))><........ > ) ) ) ) ) > ( ( ( ( ( Prof. Philippe Grosjean > ) ) ) ) ) > ( ( ( ( ( Numerical Ecology of Aquatic Systems > ) ) ) ) ) Mons-Hainaut University, Belgium > ( ( ( ( ( > .............................................................. > > _______________________________________________ > R-SIG-GUI mailing list > R-SIG-GUI@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-gui > > -- View this message in context: http://n2.nabble.com/tcltk-internationalization-for-built-in-buttons-tp1484614p1485165.html Sent from the R Sig Gui mailing list archive at Nabble.com. _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui