diff options
author | dgp <dgp@users.sourceforge.net> | 2004-03-31 18:51:33 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2004-03-31 18:51:33 (GMT) |
commit | 03a3d8dc8271e6c1ca75b6529a673c431e801eac (patch) | |
tree | a8cc6113cdcf6ec1a36ccc0ef9eac901223c94f9 /library/msgcat/msgcat.tcl | |
parent | 34514ef72eb3cbedf0f2fc0fb52069dc84514945 (diff) | |
download | tcl-03a3d8dc8271e6c1ca75b6529a673c431e801eac.zip tcl-03a3d8dc8271e6c1ca75b6529a673c431e801eac.tar.gz tcl-03a3d8dc8271e6c1ca75b6529a673c431e801eac.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.
Diffstat (limited to 'library/msgcat/msgcat.tcl')
-rw-r--r-- | library/msgcat/msgcat.tcl | 22 |
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 + } } } # |