File: setLanguage.Rd

package info (click to toggle)
r-cran-tcltk2 1.2-10-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,356 kB
  • ctags: 1,386
  • sloc: tcl: 37,888; ansic: 792; python: 324; sh: 68; sed: 16; makefile: 1
file content (54 lines) | stat: -rwxr-xr-x 1,656 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
\name{setLanguage}
\alias{setLanguage}
\alias{getLanguage}

\title{ Change or get the language used in R and Tcl/Tk }
\description{
  The function changes dynamically the language used by both R (messages only)
  and Tcl/Tk, or it retrieves its current value.
}
\usage{
setLanguage(lang)
getLanguage()
}

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

\value{
  \code{setLanguage()} returns \code{TRUE} if language was successfully changed
  in Tcl/Tk, \code{FALSE} otherwise. \code{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.
}

\author{ Philippe Grosjean }

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

\examples{
## 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)
}
}

\keyword{ utilities }

\concept{ Tcl/Tk language translation }