From e443a842dd7dea82904ccd8567cb55e14aa6c73d Mon Sep 17 00:00:00 2001 From: stanton Date: Wed, 9 Dec 1998 01:13:51 +0000 Subject: * library/msgcat1.0/msgcat.tcl: changed mc to invoke mcunknown in the calling context, changed locale lookups to be case insensitive --- ChangeLog | 5 ++++ doc/msgcat.n | 5 +++- library/msgcat/msgcat.tcl | 9 ++++--- library/msgcat1.0/msgcat.tcl | 9 ++++--- tests/msgcat.test | 61 ++++++++++++-------------------------------- tests/parse.test | 5 +++- 6 files changed, 40 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4d2113..60f80e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1998-12-08 + + * library/msgcat1.0/msgcat.tcl: changed mc to invoke mcunknown in + the calling context, changed locale lookups to be case insensitive + 1998-12-07 * generic/tclAlloc.c (TclpRealloc): Fixed a memory allocation bug diff --git a/doc/msgcat.n b/doc/msgcat.n index ce72a74..1732678 100644 --- a/doc/msgcat.n +++ b/doc/msgcat.n @@ -89,7 +89,10 @@ a translation for \fIsrc-string\fR is not defined in the current locale. The default action is to return \fIsrc-string\fR. This procedure can be redefined by the application, for example to log error messages for each unknown -string. +string. The \fB::msgcat::mcunknown\fB procedure is invoked at the +same stack context as the call to \fB::msgcat::mc\fR. The return vaue +of \fB::msgcat::mcunknown\fB is used as the return vaue for the call +to \fB::msgcat::mc\fR. .SH "LOCALE AND SUBLOCALE SPECIFICATION" .PP diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 61b8327..c112718 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.1.2.3 1998/12/07 20:56:53 stanton Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.1.2.4 1998/12/09 01:13:51 stanton Exp $ package provide msgcat 1.0 @@ -48,7 +48,8 @@ proc msgcat::mc {src} { } } # we have not found the translation - return [mcunknown $::msgcat::locale $src] + return [uplevel 1 [list [namespace origin mcunknown] \ + $::msgcat::locale $src]] } # msgcat::mclocale -- @@ -77,7 +78,7 @@ proc msgcat::mclocale {args} { foreach part [split $args _] { set word [string trimleft "${word}_${part}" _] set ::msgcat::loclist \ - [linsert $::msgcat::loclist 0 $word] + [linsert $::msgcat::loclist 0 [string tolower $word]] } } return $::msgcat::locale @@ -141,7 +142,7 @@ proc msgcat::mcset {locale src {dest ""}} { set ns [uplevel {namespace current}] - set ::msgcat::msgs($locale,$ns,$src) $dest + set ::msgcat::msgs([string tolower $locale],$ns,$src) $dest return $dest } diff --git a/library/msgcat1.0/msgcat.tcl b/library/msgcat1.0/msgcat.tcl index 61b8327..c112718 100644 --- a/library/msgcat1.0/msgcat.tcl +++ b/library/msgcat1.0/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.1.2.3 1998/12/07 20:56:53 stanton Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.1.2.4 1998/12/09 01:13:51 stanton Exp $ package provide msgcat 1.0 @@ -48,7 +48,8 @@ proc msgcat::mc {src} { } } # we have not found the translation - return [mcunknown $::msgcat::locale $src] + return [uplevel 1 [list [namespace origin mcunknown] \ + $::msgcat::locale $src]] } # msgcat::mclocale -- @@ -77,7 +78,7 @@ proc msgcat::mclocale {args} { foreach part [split $args _] { set word [string trimleft "${word}_${part}" _] set ::msgcat::loclist \ - [linsert $::msgcat::loclist 0 $word] + [linsert $::msgcat::loclist 0 [string tolower $word]] } } return $::msgcat::locale @@ -141,7 +142,7 @@ proc msgcat::mcset {locale src {dest ""}} { set ns [uplevel {namespace current}] - set ::msgcat::msgs($locale,$ns,$src) $dest + set ::msgcat::msgs([string tolower $locale],$ns,$src) $dest return $dest } diff --git a/tests/msgcat.test b/tests/msgcat.test index 92e5c4b..a207878 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -12,7 +12,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.test,v 1.1.2.1 1998/12/07 20:56:54 stanton Exp $ +# RCS: @(#) $Id: msgcat.test,v 1.1.2.2 1998/12/09 01:13:52 stanton Exp $ if {[string compare test [info procs test]] == 1} then {source defs} @@ -40,46 +40,37 @@ set oldlocale [::msgcat::mclocale] test msgcat-1.1 {::msgcat::mclocale default} { ::msgcat::mclocale } {C} - test msgcat-1.2 {::msgcat::mcpreferences, single element} { ::msgcat::mcpreferences -} {C} - +} {c} test msgcat-1.3 {::msgcat::mclocale, single element} { ::msgcat::mclocale en } {en} - test msgcat-1.4 {::msgcat::mclocale, single element} { ::msgcat::mclocale } {en} - test msgcat-1.5 {::msgcat::mcpreferences, single element} { ::msgcat::mcpreferences } {en} - test msgcat-1.6 {::msgcat::mclocale, two elements} { ::msgcat::mclocale en_US } {en_US} - test msgcat-1.7 {::msgcat::mclocale, two elements} { + ::msgcat::mclocale en_US ::msgcat::mclocale } {en_US} - test msgcat-1.8 {::msgcat::mcpreferences, two elements} { ::msgcat::mcpreferences -} {en_US en} - +} {en_us en} test msgcat-1.9 {::msgcat::mclocale, three elements} { ::msgcat::mclocale en_US_funky } {en_US_funky} - test msgcat-1.10 {::msgcat::mclocale, three elements} { ::msgcat::mclocale } {en_US_funky} - test msgcat-1.11 {::msgcat::mcpreferences, three elements} { ::msgcat::mcpreferences -} {en_US_funky en_US en} +} {en_us_funky en_us en} # # Test mcset and mcc, ensuring that namespace partitioning @@ -89,21 +80,17 @@ test msgcat-1.11 {::msgcat::mcpreferences, three elements} { test msgcat-2.1 {::msgcat::mcset, global scope} { ::msgcat::mcset foo_BAR text1 text2 } {text2} - test msgcat-2.2 {::msgcat::mcset, global scope, default} { ::msgcat::mcset foo_BAR text3 } {text3} - test msgcat-2.2 {::msgcat::mcset, namespace overlap} { namespace eval bar {::msgcat::mcset foo_BAR con1 con1bar} namespace eval baz {::msgcat::mcset foo_BAR con1 con1baz} } {con1baz} - test msgcat-2.3 {::msgcat::mcset, namespace overlap} { ::msgcat::mclocale foo_BAR namespace eval bar {::msgcat::mc con1} } {con1bar} - test msgcat-2.4 {::msgcat::mcset, namespace overlap} { ::msgcat::mclocale foo_BAR namespace eval baz {::msgcat::mc con1} @@ -138,68 +125,53 @@ test msgcat-3.1 {::msgcat::mcset, overlap} { ::msgcat::mcset foo_BAR ov3 ov3_foo_BAR ::msgcat::mcset foo_BAR_baz ov3 ov3_foo_BAR_baz } {ov3_foo_BAR_baz} - # top level, locale foo - test msgcat-3.2 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo ::msgcat::mc ov1 } {ov1_foo} - test msgcat-3.3 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo ::msgcat::mc ov2 } {ov2_foo} - test msgcat-3.4 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo ::msgcat::mc ov3 } {ov3_foo} - test msgcat-3.5 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo ::msgcat::mc ov4 } {ov4} - # second level, locale foo_BAR - test msgcat-3.6 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR ::msgcat::mc ov1 } {ov1_foo} - test msgcat-3.7 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR ::msgcat::mc ov2 } {ov2_foo_BAR} - test msgcat-3.8 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR ::msgcat::mc ov3 } {ov3_foo_BAR} - test msgcat-3.9 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR ::msgcat::mc ov4 } {ov4} - # third level, locale foo_BAR_baz - test msgcat-3.10 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR_baz ::msgcat::mc ov1 } {ov1_foo} - test msgcat-3.11 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR_baz ::msgcat::mc ov2 } {ov2_foo_BAR} - test msgcat-3.12 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR_baz ::msgcat::mc ov3 } {ov3_foo_BAR_baz} - test msgcat-3.13 {::msgcat::mcset, overlap} { ::msgcat::mclocale foo_BAR_baz ::msgcat::mc ov4 @@ -213,17 +185,14 @@ test msgcat-3.13 {::msgcat::mcset, overlap} { test msgcat-4.1 {::msgcat::mcunknown, default} { ::msgcat::mcset foo unk1 "unknown 1" } {unknown 1} - test msgcat-4.2 {::msgcat::mcunknown, default} { ::msgcat::mclocale foo ::msgcat::mc unk1 } {unknown 1} - test msgcat-4.3 {::msgcat::mcunknown, default} { ::msgcat::mclocale foo ::msgcat::mc unk2 } {unk2} - test msgcat-4.4 {::msgcat::mcunknown, overridden} { rename ::msgcat::mcunknown oldproc proc ::msgcat::mcunknown {dom s} { @@ -235,7 +204,6 @@ test msgcat-4.4 {::msgcat::mcunknown, overridden} { rename oldproc ::msgcat::mcunknown set result } {unknown 1} - test msgcat-4.5 {::msgcat::mcunknown, overridden} { rename ::msgcat::mcunknown oldproc proc ::msgcat::mcunknown {dom s} { @@ -247,6 +215,18 @@ test msgcat-4.5 {::msgcat::mcunknown, overridden} { rename oldproc ::msgcat::mcunknown set result } {unknown:foo:unk2} +test msgcat-4.6 {::msgcat::mcunknown, uplevel context} { + rename ::msgcat::mcunknown oldproc + proc ::msgcat::mcunknown {dom s} { + return "unknown:$dom:$s:[info level]" + } + ::msgcat::mclocale foo + set result [::msgcat::mc unk2] + rename ::msgcat::mcunknown {} + rename oldproc ::msgcat::mcunknown + set result +} {unknown:foo:unk2:1} + # # Test mcload. Need to set up an environment for @@ -267,12 +247,10 @@ test msgcat-5.1 {::msgcat::mcload} { ::msgcat::mclocale en ::msgcat::mcload msgdir } {1} - test msgcat-5.2 {::msgcat::mcload} { ::msgcat::mclocale en_US ::msgcat::mcload msgdir } {2} - test msgcat-5.3 {::msgcat::mcload} { ::msgcat::mclocale en_US_funky ::msgcat::mcload msgdir @@ -285,27 +263,22 @@ test msgcat-5.4 {::msgcat::mcload} { ::msgcat::mclocale en_US_notexist ::msgcat::mcload msgdir } {2} - test msgcat-5.5 {::msgcat::mcload} { ::msgcat::mclocale no_FI_notexist ::msgcat::mcload msgdir } {0} - test msgcat-5.6 {::msgcat::mcload} { ::msgcat::mclocale en ::msgcat::mc abc } {abc-en} - test msgcat-5.7 {::msgcat::mcload} { ::msgcat::mclocale en_US ::msgcat::mc abc } {abc-en_US} - test msgcat-5.8 {::msgcat::mcload} { ::msgcat::mclocale en_US_funky ::msgcat::mc abc } {abc-en_US_funky} - test msgcat-5.9 {::msgcat::mcload} { rename ::msgcat::mcunknown oldproc proc ::msgcat::mcunknown {dom s} { diff --git a/tests/parse.test b/tests/parse.test index 53afce9..c6d5a7a 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -7,7 +7,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: parse.test,v 1.1.2.5 1998/12/02 21:46:05 stanton Exp $ +# RCS: @(#) $Id: parse.test,v 1.1.2.6 1998/12/09 01:13:52 stanton Exp $ if {[info commands testparser] == {}} { puts "This application hasn't been compiled with the \"testparser\"" @@ -709,6 +709,9 @@ test parse-15.55 {CommandComplete procedure} { test parse-15.56 {CommandComplete procedure} { info complete "set x [bytestring \0]; \{" } 0 +test parse-15.57 {CommandComplete procedure} { + info complete "# Comment should be complete command" +} 1 catch {unset a} -- cgit v0.12