Compare commits

...
6 changed files with 57 additions and 6 deletions
Regular → Executable
+2
View File
@@ -8841,3 +8841,5 @@ improvements to regexp engine from Postgres (lane,porter,fellows,seltenreich)
2017-09-02 (bug)[0e4d88] replace command, delete trace kills namespace (porter)
--- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tcl/ for details
2017-12-11 (TIP 490) add oo support for msgcat (fellows)
Regular → Executable
+22
View File
@@ -50,6 +50,8 @@ msgcat \- Tcl message catalog
.sp
\fB::msgcat::mcforgetpackage\fR
.VE "TIP 412"
.sp
\fBmixin msgcat::MessageCatalogAware\fR
.BE
.SH DESCRIPTION
.PP
@@ -231,6 +233,26 @@ Note that this routine is only called if the concerned package did not set a pac
.
The calling package clears all its state within the \fBmsgcat\fR package including all settings and translations.
.VE "TIP 412"
.RE
.TP
.VS "TIP 490"
\fBmixin msgcat::MessageCatalogAware\fR
.
A class within a package should include this line to make message catalog commands (mc, mcmax, mcexists) work.
.PP
.CS
namespace eval ::foo {
msgcat::mcload $dir/msgs
oo::class create Foo {
mixin msgcat::MessageCatalogAware
method printMessage {x y} {
puts [my mc "FooPrintMessage(%d,%d)" $x $y]
}
}
}
package provide foo 1.0 .CE
.VE "TIP 490"
.PP
.SH "LOCALE SPECIFICATION"
.PP
Regular → Executable
+28 -1
View File
@@ -14,7 +14,7 @@
package require Tcl 8.5-
# When the version number changes, be sure to update the pkgIndex.tcl file,
# and the installation directory in the Makefiles.
package provide msgcat 1.6.1
package provide msgcat 1.6.2
namespace eval msgcat {
namespace export mc mcexists mcload mclocale mcmax mcmset mcpreferences mcset\
@@ -1106,6 +1106,33 @@ proc msgcat::ConvertLocale {value} {
return $ret
}
# Make oo classes message catalog aware
namespace eval ::msgcat {
oo::class create MessageCatalogAware {
forward mc ::msgcat::OOBridge ::msgcat::mc
forward mcmax ::msgcat::OOBridge ::msgcat::mcmax
forward mcexists ::msgcat::OOBridge ::msgcat::mcexists
# Tricky point: methods are not usefully callable from outside the
# class hierarchy
unexport mc mcmax mcexists
}
}
# helper function to find package namespace and evaluate mc commands within
# this namespace
proc ::msgcat::OOBridge {cmd args} {
if {[catch {
# Tricky point: [self class] needs to run in the caller
set ns [namespace qualifiers [uplevel 1 {self class}]]
}]} {
# Not a class-defined method (so we got an error); use instance instead
set ns [namespace qualifiers [uplevel 1 self]]
}
apply [list {cmd args} {$cmd {*}$args} $ns] $cmd {*}$args
# DKF: alternative - one may give a better error trace
# namespace eval ::$ns [list $cmd {*}$args]
}
# Initialize the default locale
proc msgcat::Init {} {
global env
Regular → Executable
+1 -1
View File
@@ -1,2 +1,2 @@
if {![package vsatisfies [package provide Tcl] 8.5-]} {return}
package ifneeded msgcat 1.6.1 [list source [file join $dir msgcat.tcl]]
package ifneeded msgcat 2.6.2 [list source [file join $dir msgcat.tcl]]
Regular → Executable
+2 -2
View File
@@ -855,8 +855,8 @@ install-libraries: libraries
do \
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \
done;
@echo "Installing package msgcat 1.6.1 as a Tcl Module";
@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.1.tm;
@echo "Installing package msgcat 1.6.2 as a Tcl Module";
@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.2.tm;
@echo "Installing package tcltest 2.4.1 as a Tcl Module";
@$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.4.1.tm;
Regular → Executable
+2 -2
View File
@@ -664,8 +664,8 @@ install-libraries: libraries install-tzdata install-msgs
do \
$(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \
done;
@echo "Installing package msgcat 1.6.1 as a Tcl Module";
@$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.6.1.tm;
@echo "Installing package msgcat 1.6.2 as a Tcl Module";
@$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.6.2.tm;
@echo "Installing package tcltest 2.4.0 as a Tcl Module";
@$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.4.0.tm;
@echo "Installing package platform 1.0.14 as a Tcl Module";