msgcat::unknown should have args, too
Closed / Fixed219105ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:10:52
OriginalBugID: 5984 Bug
Version: 8.4a1
SubmitDate: '2000-07-06'
LastModified: '2000-07-06'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: ericm
OS: Linux-SuSE
FixedDate: '2000-07-06'
FixedInVersion: 8.4a2
ClosedDate: '2000-10-25'
Name:
Christian Krone
Comments:
The comment in msgcat.tcl above the mcunknown command suggests, that
users of the msgcat package
can write their own mcunknown proc. So calling this function with
additional arguments can
generate errors, if someone really created an own version with the old
interface.
But I think, this should be no problem, since the additional arguments
are only given to mcunknown
if they are specified for mc. And only user who knows about the
additional argument will do so.
DesiredBehavior:
It's great, that the msgcat::mc command has got an additional args argument.
This way I don't need no longer do the format one layer above by myself.
But it is essential for me, that the msgcat::mcunknown proc gets the
additional argument, too. Otherwise I have to make a msgfile for the C locale,
which contains only translations from the format strings into itself.
Patch:
*** msgcat.tcl.orgTue Apr 11 23:16:18 2000
--- msgcat.tclWed Jul 5 17:57:46 2000
***************
*** 67,73 ****
}
# we have not found the translation
return [uplevel 1 [list [namespace origin mcunknown] \
! $::msgcat::locale $src]]
}
# msgcat::mclocale --
--- 67,73 ----
}
# we have not found the translation
return [uplevel 1 [list [namespace origin mcunknown] \
! $::msgcat::locale $src] $args]
}
# msgcat::mclocale --
***************
*** 170,185 ****
#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.
#
# Arguments:
#localeThe current locale.
#srcThe string to be translated.
#
# Results:
#Returns the translated value.
! proc msgcat::mcunknown {locale src} {
! return $src
}
# Initialize the default locale
--- 170,192 ----
#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:
#localeThe current locale.
#srcThe string to be translated.
+ #argsArgs to pass to the format command
#
# Results:
#Returns the translated value.
! proc msgcat::mcunknown {locale src args} {
! if {[llength $args]} {
! return [eval {format $src} $args]
! } else {
! return $src
! }
}
# Initialize the default locale
*** msgcat.test.orgWed Jul 5 18:11:21 2000
--- msgcat.testWed Jul 5 12:58:43 2000
***************
*** 401,406 ****
--- 401,409 ----
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
PatchFiles:
msgcat.tcl
msgcat.test
Thanks for the great patch; I've applied it to the sources in CVS, and this fix will go out with Tcl/Tk 8.4a2.
Eric Melski The Other Tcl Guy
ericm at ajubasolutions.com Ajuba Solutions
-- 07/06/2000 ericm
welch Closed ticket [219105ffff].
[History diff]2000-10-26 08:34:56
dgp Open ticket [219105ffff].
[History diff]2001-04-20 02:48:59
dgp Closed ticket [219105ffff].
[History diff]2001-04-20 02:49:41
Log in (anonymous is fine) to add a comment.