summaryrefslogtreecommitdiffstats
path: root/library/msgcat
diff options
context:
space:
mode:
authordgp <dgp@noemail.net>2004-03-31 18:51:33 (GMT)
committerdgp <dgp@noemail.net>2004-03-31 18:51:33 (GMT)
commit3cfaa547cd1d597cd1b9a6957785e67310951a5b (patch)
treea8cc6113cdcf6ec1a36ccc0ef9eac901223c94f9 /library/msgcat
parenta6b36c33884527030180034d4ae19ad973e79265 (diff)
downloadtcl-3cfaa547cd1d597cd1b9a6957785e67310951a5b.zip
tcl-3cfaa547cd1d597cd1b9a6957785e67310951a5b.tar.gz
tcl-3cfaa547cd1d597cd1b9a6957785e67310951a5b.tar.bz2
* doc/msgcat.n: Clarified message catalog file encodings. [Bug 811457]
* 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. [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. FossilOrigin-Name: 55d1d19622dfd8b38a545664913e75ac12a821d2
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
+ }
}
}
#