File: imgmsg.tcl

package info (click to toggle)
libtk-img 1%3A1.3-15etch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,144 kB
  • ctags: 14,513
  • sloc: ansic: 110,000; sh: 65,326; tcl: 2,844; asm: 996; cpp: 560; pascal: 536; makefile: 436
file content (33 lines) | stat: -rw-r--r-- 874 bytes parent folder | download | duplicates (9)
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
#
#    This script activates msgcat if available, otherwise it
#    defines a minimal number of functions to make Internationalization
#    within Img possible using Tk 8.0 or higher.
#
if {[catch {package require msgcat}]} {
    if {[info exists env(LANG)]} {
	set fileName [file join [file dirname [info script]] msgs \
		[string tolower [string range $env(LANG) 0 1]].msg]
	if {[file readable $fileName]} {
	    namespace eval msgcat {
		proc mcset {args} {
		    global ::msgs
		    if {[llength $args] > 2} {
			set msgs([lindex $args 1]) [lindex $args 2]
		    }
		}
	    }
	    source $fileName
	}
    }
    proc mc {string} {
	global msgs
	if {[info exists msgs($string)]} {
	    return [set msgs($string)]
	} else {
	    return $string
	}
    }
} else {
    ::msgcat::mcload [file join [file dirname [info script]] msgs]
    catch {namespace import ::msgcat::mc}
}