setLanguage: Change or get the language used in R and Tcl/Tk

Description Usage Arguments Value Note Author(s) Examples

Description

The function changes dynamically the language used by both R (messages only) and Tcl/Tk, or it retrieves its current value.

Usage

1
2

Arguments

lang

an identification for the targeted language, for instance, \"en\" for English, \"fr\" for French, \"de\" for German, \"it\" for Italian, etc.

Value

setLanguage() returns TRUE if language was successfully changed in Tcl/Tk, FALSE otherwise. getLanguage() returns a string with current language in use for R, or an empty string if it cannot determinate which is the language currently used.

Note

You need the msgcat Tcl package to use this (but it is provided with all recent distributions of Tcl/Tk by default)

Author(s)

Philippe Grosjean

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Determine which language is currently in use in R
oldlang <- getLanguage()
if (oldlang != "") {
    ## Switch to English and test a command that issues a warning
    if (setLanguage("en_US")) 1:3 + 1:2
    ## Switch to French and test a command that issues a warning
    if (setLanguage("fr_FR")) 1:3 + 1:2
    ## Switch to German and test a command that issues a warning
    if (setLanguage("de_DE")) 1:3 + 1:2
    ## Switch to Italian and test a command that issues a warning
    if (setLanguage("it_IT")) 1:3 + 1:2
    ## Etc..

    ## Restore previous language
    setLanguage(oldlang)
}

tcltk2 documentation built on May 2, 2019, 9:37 a.m.