summaryrefslogtreecommitdiffstats
path: root/library/msgcat
diff options
context:
space:
mode:
Diffstat (limited to 'library/msgcat')
-rw-r--r--library/msgcat/msgcat.tcl22
1 files changed, 15 insertions, 7 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl
index ec5f584..4db7890 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.20 2004/03/31 02:03:02 dgp Exp $
+# RCS: @(#) $Id: msgcat.tcl,v 1.21 2004/03/31 18:51:33 dgp Exp $
package require Tcl 8.5
# When the version number changes, be sure to update the pkgIndex.tcl file,
@@ -233,10 +233,13 @@ proc msgcat::mclocale {args} {
set Loclist {}
set word ""
foreach part [split $Locale _] {
- set word [string trimleft "${word}_${part}" _]
- set Loclist [linsert $Loclist 0 $word]
+ set word [string trim "${word}_${part}" _]
+ if {$word ne [lindex $Loclist 0]} {
+ set Loclist [linsert $Loclist 0 $word]
+ }
}
lappend Loclist {}
+ set Locale [lindex $Loclist 0]
}
return $Locale
}
@@ -417,8 +420,10 @@ proc msgcat::ConvertLocale {value} {
# (@(.*))? # Match (optional) "modifier"; starts with @
# $ # Match all the way to the end
# } $value -> language _ territory _ codeset _ modifier
- regexp {^([^_.@]*)(_([^.@]*))?([.]([^@]*))?(@(.*))?$} $value \
- -> language _ territory _ codeset _ modifier
+ if {![regexp {^([^_.@]+)(_([^.@]*))?([.]([^@]*))?(@(.*))?$} $value \
+ -> language _ territory _ codeset _ modifier]} {
+ return -code error "invalid locale '$value': empty language part"
+ }
set ret $language
if {[string length $territory]} {
append ret _$territory
@@ -436,8 +441,11 @@ proc msgcat::Init {} {
#
foreach varName {LC_ALL LC_MESSAGES LANG} {
if {[info exists ::env($varName)] && ("" ne $::env($varName))} {
- mclocale [ConvertLocale $::env($varName)]
- return
+ if {![catch {
+ mclocale [ConvertLocale $::env($varName)]
+ }]} {
+ return
+ }
}
}
#