diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-12-16 09:26:05 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-12-16 09:26:05 (GMT) |
commit | e68e8b910b85a97d8b4804c4b193bd92372855a8 (patch) | |
tree | 0f0f60fa8fbdb70a91b27d2f4e4a046b37fb4580 /library | |
parent | 56dedeb231281fb437f1caa29d16938b44a41f69 (diff) | |
download | tcl-e68e8b910b85a97d8b4804c4b193bd92372855a8.zip tcl-e68e8b910b85a97d8b4804c4b193bd92372855a8.tar.gz tcl-e68e8b910b85a97d8b4804c4b193bd92372855a8.tar.bz2 |
[Bug 2913616]: Make msgcat package work in safe interpreters.
Diffstat (limited to 'library')
-rw-r--r-- | library/msgcat/msgcat.tcl | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 660d435..f3e79d8 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.27 2009/11/18 21:45:36 nijtmans Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.28 2009/12/16 09:26:24 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 } @@ -477,9 +478,11 @@ proc msgcat::Init {} { # On Windows, try to set locale depending on registry settings, # 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]} { + if {[catch { + package require registry + set key {HKEY_CURRENT_USER\Control Panel\International} + 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 } |