summaryrefslogtreecommitdiffstats
path: root/library/msgcat
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-12-16 09:31:08 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-12-16 09:31:08 (GMT)
commit2645c7c322e609d8c5ca99ae8718d29b2f8a3b4c (patch)
tree4e46af0e1efb25fad9de76aff5c1ae764cd3f960 /library/msgcat
parent39b862880057eacb47d056f15a748a498d497788 (diff)
downloadtcl-2645c7c322e609d8c5ca99ae8718d29b2f8a3b4c.zip
tcl-2645c7c322e609d8c5ca99ae8718d29b2f8a3b4c.tar.gz
tcl-2645c7c322e609d8c5ca99ae8718d29b2f8a3b4c.tar.bz2
[Bug 2913616]: Make msgcat package work in safe interpreters.
Diffstat (limited to 'library/msgcat')
-rw-r--r--library/msgcat/msgcat.tcl23
1 files changed, 13 insertions, 10 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl
index ccf4054..486c106 100644
--- a/library/msgcat/msgcat.tcl
+++ b/library/msgcat/msgcat.tcl
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: msgcat.tcl,v 1.26 2006/11/03 00:34:52 hobbs Exp $
+# RCS: @(#) $Id: msgcat.tcl,v 1.26.4.1 2009/12/16 09:31:08 dkf Exp $
package require Tcl 8.5
# When the version number changes, be sure to update the pkgIndex.tcl file,
@@ -442,13 +442,15 @@ proc msgcat::ConvertLocale {value} {
# Initialize the default locale
proc msgcat::Init {} {
+ global env tcl_platform
+
#
# set default locale, try to get from environment
#
foreach varName {LC_ALL LC_MESSAGES LANG} {
- if {[info exists ::env($varName)] && ("" ne $::env($varName))} {
+ if {[info exists env($varName)] && ("" ne $env($varName))} {
if {![catch {
- mclocale [ConvertLocale $::env($varName)]
+ mclocale [ConvertLocale $env($varName)]
}]} {
return
}
@@ -457,8 +459,7 @@ proc msgcat::Init {} {
#
# On Darwin, fallback to current CFLocale identifier if available.
#
- if {$::tcl_platform(os) eq "Darwin" && $::tcl_platform(platform) eq "unix"
- && [info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} {
+ if {[info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} {
if {![catch {
mclocale [ConvertLocale $::tcl::mac::locale]
}]} {
@@ -469,7 +470,7 @@ proc msgcat::Init {} {
# The rest of this routine is special processing for Windows;
# all other platforms, get out now.
#
- if { $::tcl_platform(platform) ne "windows" } {
+ if {$tcl_platform(platform) ne "windows"} {
mclocale C
return
}
@@ -478,9 +479,11 @@ proc msgcat::Init {} {
# or fall back on locale of "C".
#
set key {HKEY_CURRENT_USER\Control Panel\International}
- if {[catch {package require registry}] \
- || [catch {registry get $key "locale"} locale]} {
- mclocale C
+ if {[catch {
+ package require registry
+ set locale [registry get $key "locale"]
+ }]} {
+ mclocale C
return
}
#
@@ -496,7 +499,7 @@ proc msgcat::Init {} {
set locale [string tolower $locale]
while {[string length $locale]} {
if {![catch {
- mclocale [ConvertLocale [dict get $WinRegToISO639 $locale]]
+ mclocale [ConvertLocale [dict get $WinRegToISO639 $locale]]
}]} {
return
}