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) } -- View this message in context: http://n2.nabble.com/tcltk-internationalization-for-built-in-buttons-tp1484614p1484614.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