diff options
author | ericm <ericm> | 2000-07-06 21:05:01 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-07-06 21:05:01 (GMT) |
commit | 003f25f16aa9d093b468f4c74a1eece63c929c88 (patch) | |
tree | f41e6aac70ba45c195c73c507ba94d6f19bf127e | |
parent | be8ba4515aaf9da7893bcb0930ca1965e0602cb3 (diff) | |
download | tcl-003f25f16aa9d093b468f4c74a1eece63c929c88.zip tcl-003f25f16aa9d093b468f4c74a1eece63c929c88.tar.gz tcl-003f25f16aa9d093b468f4c74a1eece63c929c88.tar.bz2 |
* tests/msgcat.test:
* library/msgcat1.0/msgcat.tcl: Applied patch from Christian
Krone, to provide extended args support for msgcat::unknown, which
is used for strings without a known translation in the current
locale [Bug: 5984].
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | library/msgcat/msgcat.tcl | 15 | ||||
-rw-r--r-- | library/msgcat1.0/msgcat.tcl | 15 | ||||
-rw-r--r-- | tests/msgcat.test | 5 |
4 files changed, 34 insertions, 9 deletions
@@ -1,3 +1,11 @@ +2000-07-06 Eric Melski <ericm@scriptics.com> + + * tests/msgcat.test: + * library/msgcat1.0/msgcat.tcl: Applied patch from Christian + Krone, to provide extended args support for msgcat::unknown, which + is used for strings without a known translation in the current + locale [Bug: 5984]. + 2000-06-29 Eric Melski <ericm@scriptics.com> * doc/msgcat.n: Doc's for mcmax function. diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 0f7d6d3..fb1aeb3 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.5 2000/06/30 06:28:27 ericm Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.6 2000/07/06 21:05:02 ericm Exp $ package provide msgcat 1.1 @@ -67,7 +67,7 @@ proc msgcat::mc {src args} { } # we have not found the translation return [uplevel 1 [list [namespace origin mcunknown] \ - $::msgcat::locale $src]] + $::msgcat::locale $src] $args] } # msgcat::mclocale -- @@ -170,16 +170,23 @@ proc msgcat::mcset {locale src {dest ""}} { # be found for a string. This routine is intended to be replaced # by an application specific routine for error reporting # purposes. The default behavior is to return the source string. +# If additional args are specified, the format command will be used +# to work them into the traslated string. # # Arguments: # locale The current locale. # src The string to be translated. +# args Args to pass to the format command # # Results: # Returns the translated value. -proc msgcat::mcunknown {locale src} { - return $src +proc msgcat::mcunknown {locale src args} { + if {[llength $args]} { + return [eval [list format $src] $args] + } else { + return $src + } } # msgcat::mcmax -- diff --git a/library/msgcat1.0/msgcat.tcl b/library/msgcat1.0/msgcat.tcl index 0f7d6d3..fb1aeb3 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.5 2000/06/30 06:28:27 ericm Exp $ +# RCS: @(#) $Id: msgcat.tcl,v 1.6 2000/07/06 21:05:02 ericm Exp $ package provide msgcat 1.1 @@ -67,7 +67,7 @@ proc msgcat::mc {src args} { } # we have not found the translation return [uplevel 1 [list [namespace origin mcunknown] \ - $::msgcat::locale $src]] + $::msgcat::locale $src] $args] } # msgcat::mclocale -- @@ -170,16 +170,23 @@ proc msgcat::mcset {locale src {dest ""}} { # be found for a string. This routine is intended to be replaced # by an application specific routine for error reporting # purposes. The default behavior is to return the source string. +# If additional args are specified, the format command will be used +# to work them into the traslated string. # # Arguments: # locale The current locale. # src The string to be translated. +# args Args to pass to the format command # # Results: # Returns the translated value. -proc msgcat::mcunknown {locale src} { - return $src +proc msgcat::mcunknown {locale src args} { + if {[llength $args]} { + return [eval [list format $src] $args] + } else { + return $src + } } # msgcat::mcmax -- diff --git a/tests/msgcat.test b/tests/msgcat.test index 04e570b..cdb42ac 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.8 2000/04/11 21:16:18 ericm Exp $ +# RCS: @(#) $Id: msgcat.test,v 1.9 2000/07/06 21:05:02 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -401,6 +401,9 @@ test msgcat-7.2 {::msgcat::mc, extra args go through to format} { test msgcat-7.3 {::msgcat::mc, errors from format are propagated} { catch {::msgcat::mc format3 "good test"} } 1 +test msgcat-7.4 {::msgcat::mc, extra args are given to unknown} { + ::msgcat::mc "this is a %s" "good test" +} "this is a good test" # Reset the locale ::msgcat::mclocale $oldlocale |