summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--library/msgcat/msgcat.tcl22
2 files changed, 25 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 7688014..de11fe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,17 @@
2004-03-29 Don Porter <dgp@users.sourceforge.net>
* doc/msgcat.n: Clarified message catalog file encodings. [Bug 811457]
- * library/msgcat/msgcat.tcl: Updated internals to make use of
- * library/msgcat/pkgIndex.tcl: [dict]s to store message catalog
+ * library/msgcat/msgcat.tcl:
+ Updated internals to make use of [dict]s to store message catalog
data and to use [source -encoding utf-8] to access catalog files.
- Thanks to Michael Sclenker. Also corrects bug to allow
- translation to an empty string. Bump to msgcat 1.4.1. [Patch 875055]
+ Thanks to Michael Sclenker. [Patch 875055, RFE 811459]
+ Corrected [mcset] to be able to successfully set a translation to
+ the empty string. [mcset $loc $src {}] was incorrectly set the
+ $loc translation of $src back to $src. Also changed [ConvertLocale]
+ to minimally require a non-empty "language" part in the locale value.
+ If not, an error raised prompts [Init] to keep looking for a valid
+ locale value, or ultimately fall back on the "C" locale. [Bug 811461].
+ * library/msgcat/pkgIndex.tcl: Bump to msgcat 1.4.1.
2004-03-30 Donal K. Fellows <donal.k.fellows@man.ac.uk>
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
+ }
}
}
#