summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2003-10-21 00:23:33 (GMT)
committerKevin B Kenny <kennykb@acm.org>2003-10-21 00:23:33 (GMT)
commit069e6b39be18f68043fb7389188c1e8d2a6afb06 (patch)
tree2ed74cd43101586ffe55de9721f1354589548214
parent7c7a39a26c9bd772bf26ae6fd1be320d392d10db (diff)
downloadtcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.zip
tcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.tar.gz
tcl-069e6b39be18f68043fb7389188c1e8d2a6afb06.tar.bz2
TIP #156: Language-Neutral Root Locale for Msgcat
-rw-r--r--ChangeLog10
-rw-r--r--doc/msgcat.n25
-rw-r--r--library/msgcat/msgcat.tcl8
-rw-r--r--tests/msgcat.test51
-rw-r--r--tools/tcl.wse.in4
-rw-r--r--unix/Makefile.in8
-rw-r--r--win/Makefile.in8
-rw-r--r--win/makefile.bc8
-rw-r--r--win/makefile.vc6
9 files changed, 82 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 47f32c7..57767aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-10-20 Kevin B. Kenny <kennykb@users.sourceforge.net>
+
+ * doc/msgcat.n:
+ * library/msgcat/msgcat.tcl (mclocale,mcload):
+ * tools/tcl.wse.in:
+ * unix/Makefile.in: Implementation of TIP#156
+ * win/makefile.bc: adding a "root locale" to
+ * win/Makefile.in: the 'msgcat' package. Advanced
+ * win/Makefile.vc: msgcat version number to 1.4.
+
2003-10-15 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* generic/tclCmdIL.c (SortInfo,etc): Reorganized so that SortInfo
diff --git a/doc/msgcat.n b/doc/msgcat.n
index 1c11f17..264af9b 100644
--- a/doc/msgcat.n
+++ b/doc/msgcat.n
@@ -7,7 +7,7 @@
'\" SCCS: @(#) msgcat.n
'\"
.so man.macros
-.TH "msgcat" n 1.3 msgcat "Tcl Bundled Packages"
+.TH "msgcat" n 1.4 msgcat "Tcl Bundled Packages"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
@@ -15,7 +15,7 @@ msgcat \- Tcl message catalog
.SH SYNOPSIS
\fBpackage require Tcl 8.2\fR
.sp
-\fBpackage require msgcat 1.3\fR
+\fBpackage require msgcat 1.4\fR
.sp
\fB::msgcat::mc \fIsrc-string\fR ?\fIarg arg ...\fR?
.sp
@@ -94,7 +94,9 @@ preference. The list is derived from the current
locale set in msgcat by \fBmsgcat::mclocale\fR, and
cannot be set independently. For example, if the
current locale is en_US_funky, then \fBmsgcat::mcpreferences\fR
-returns {en_US_funky en_US en}.
+.VS 1.4
+returns \fB{en_US_funky en_US en {}}\fR.
+.VE
.TP
\fB::msgcat::mcload \fIdirname\fR
Searches the specified directory for files that match
@@ -167,10 +169,13 @@ locale of ``C''.
.PP
When a locale is specified by the user, a ``best match'' search is
performed during string translation. For example, if a user specifies
-en_GB_Funky, the locales ``en_GB_Funky'', ``en_GB'', and ``en'' are
-searched in order until a matching translation string is found. If no
-translation string is available, then \fB::msgcat::unknown\fR is
-called.
+.VS 1.4
+en_GB_Funky, the locales ``en_GB_Funky'', ``en_GB'', ``en'' and ``''
+(the empty string)
+.VE
+are searched in order until a matching translation
+string is found. If no translation string is available, then
+\fB::msgcat::unknown\fR is called.
.SH "NAMESPACES AND MESSAGE CATALOGS"
.PP
@@ -236,6 +241,12 @@ followed by ``.msg''. For example:
es.msg -- spanish
en_gb.msg -- United Kingdom English
.CE
+.VS
+\fIException:\fR The message file for the root locale ``'' is
+called \fBROOT.msg\fR. This exception is made so as not to
+cause peculiar behavior, such as marking the message file as
+``hidden'' on Unix file systems.
+.VE
.IP [3]
The file contains a series of calls to \fBmcset\fR and
\fBmcmset\fR, setting the necessary translation strings
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl
index 93c7214..08de274 100644
--- a/library/msgcat/msgcat.tcl
+++ b/library/msgcat/msgcat.tcl
@@ -10,12 +10,12 @@
# 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.18 2003/08/06 23:02:05 dgp Exp $
+# RCS: @(#) $Id: msgcat.tcl,v 1.19 2003/10/21 00:23:34 kennykb Exp $
package require Tcl 8.2
# When the version number changes, be sure to update the pkgIndex.tcl file,
# and the installation directory in the Makefiles.
-package provide msgcat 1.3.1
+package provide msgcat 1.4
namespace eval msgcat {
namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \
@@ -234,6 +234,7 @@ proc msgcat::mclocale {args} {
set word [string trimleft "${word}_${part}" _]
set Loclist [linsert $Loclist 0 $word]
}
+ lappend Loclist {}
}
return $Locale
}
@@ -268,6 +269,9 @@ proc msgcat::mcpreferences {} {
proc msgcat::mcload {langdir} {
set x 0
foreach p [mcpreferences] {
+ if { $p eq {} } {
+ set p ROOT
+ }
set langfile [file join $langdir $p.msg]
if {[file exists $langfile]} {
incr x
diff --git a/tests/msgcat.test b/tests/msgcat.test
index 96a0ace..dac4a98 100644
--- a/tests/msgcat.test
+++ b/tests/msgcat.test
@@ -12,15 +12,15 @@
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.
#
-# RCS: @(#) $Id: msgcat.test,v 1.12 2003/03/26 22:55:44 dgp Exp $
+# RCS: @(#) $Id: msgcat.test,v 1.13 2003/10/21 00:23:34 kennykb Exp $
package require Tcl 8.2
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
return
}
-if {[catch {package require msgcat 1.3}]} {
- puts stderr "Skipping tests in [info script]. No msgcat 1.3 found to test."
+if {[catch {package require msgcat 1.4}]} {
+ puts stderr "Skipping tests in [info script]. No msgcat 1.4 found to test."
return
}
@@ -111,7 +111,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result en
+ } -result {en {}}
test msgcat-1.6 {mclocale set, two elements} -setup {
variable locale [mclocale]
@@ -137,7 +137,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result {en_us en}
+ } -result {en_us en {}}
test msgcat-1.9 {mclocale set, three elements} -setup {
variable locale [mclocale]
@@ -163,7 +163,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcpreferences
- } -result {en_us_funky en_us en}
+ } -result {en_us_funky en_us en {}}
# Tests msgcat-2.*: [mcset], [mcmset], namespace partitioning
@@ -246,12 +246,13 @@ namespace eval ::msgcat::test {
# (e.g. en_UK) will search less specific locales
# (e.g. en) for translation strings.
#
- # Do this for the 12 permutations of
+ # Do this for the 15 permutations of
# locales: {foo foo_BAR foo_BAR_baz}
- # strings: {ov1 ov2 ov3 ov4}
- # locale foo defines ov1, ov2, ov3
- # locale foo_BAR defines ov2, ov3
- # locale foo_BAR_BAZ defines ov3
+ # strings: {ov0 ov1 ov2 ov3 ov4}
+ # locale ROOT defines ov0, ov1, ov2, ov3
+ # locale foo defines ov1, ov2, ov3
+ # locale foo_BAR defines ov2, ov3
+ # locale foo_BAR_BAZ defines ov3
# (ov4 is defined in none)
# So,
# ov3 should be resolved in foo, foo_BAR, foo_BAR_baz
@@ -264,16 +265,23 @@ namespace eval ::msgcat::test {
variable count 2
variable result
array set result {
- foo,ov1 ov1_foo foo,ov2 ov2_foo foo,ov3 ov3_foo foo,ov4 ov4
- foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR foo_BAR,ov3 ov3_foo_BAR
- foo_BAR,ov4 ov4 foo_BAR_baz,ov1 ov1_foo foo_BAR_baz,ov2 ov2_foo_BAR
+ foo,ov0 ov0_ROOT foo,ov1 ov1_foo foo,ov2 ov2_foo
+ foo,ov3 ov3_foo foo,ov4 ov4
+ foo_BAR,ov0 ov0_ROOT foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR
+ foo_BAR,ov3 ov3_foo_BAR foo_BAR,ov4 ov4
+ foo_BAR_baz,ov0 ov0_ROOT foo_BAR_baz,ov1 ov1_foo
+ foo_BAR_baz,ov2 ov2_foo_BAR
foo_BAR_baz,ov3 ov3_foo_BAR_baz foo_BAR_baz,ov4 ov4
}
variable loc
variable string
foreach loc {foo foo_BAR foo_BAR_baz} {
- foreach string {ov1 ov2 ov3 ov4} {
+ foreach string {ov0 ov1 ov2 ov3 ov4} {
test msgcat-3.$count {mcset, overlap} -setup {
+ mcset {} ov0 ov0_ROOT
+ mcset {} ov1 ov1_ROOT
+ mcset {} ov2 ov2_ROOT
+ mcset {} ov3 ov3_ROOT
mcset foo ov1 ov1_foo
mcset foo ov2 ov2_foo
mcset foo ov3 ov3_foo
@@ -364,9 +372,12 @@ namespace eval ::msgcat::test {
# Tests msgcat-5.*: [mcload]
- variable locales {foo foo_BAR foo_BAR_baz}
+ variable locales {{} foo foo_BAR foo_BAR_baz}
makeDirectory msgdir
foreach loc $locales {
+ if { $loc eq {} } {
+ set loc ROOT
+ }
makeFile "::msgcat::mcset $loc abc abc-$loc" \
[string tolower [file join msgdir $loc.msg]]
}
@@ -379,12 +390,12 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result $count
+ } -result [expr { $count+1 }]
incr count
}
# Even though foo_BAR_notexist does not exist,
- # foo_BAR and foo should be loaded.
+ # foo_BAR, foo and the root should be loaded.
test msgcat-5.4 {mcload} -setup {
variable locale [mclocale]
mclocale foo_BAR_notexist
@@ -392,7 +403,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result 2
+ } -result 3
test msgcat-5.5 {mcload} -setup {
variable locale [mclocale]
@@ -401,7 +412,7 @@ namespace eval ::msgcat::test {
mclocale $locale
} -body {
mcload [file join [temporaryDirectory] msgdir]
- } -result 0
+ } -result 1
test msgcat-5.6 {mcload} -setup {
variable locale [mclocale]
diff --git a/tools/tcl.wse.in b/tools/tcl.wse.in
index d21b4d6..44779a1 100644
--- a/tools/tcl.wse.in
+++ b/tools/tcl.wse.in
@@ -1063,12 +1063,12 @@ item: If/While Statement
end
item: Install File
Source=${__TCLBASEDIR__}\library\msgcat\pkgIndex.tcl
- Destination=%MAINDIR%\lib\tcl%VER%\msgcat1.2\pkgIndex.tcl
+ Destination=%MAINDIR%\lib\tcl%VER%\msgcat1.4\pkgIndex.tcl
Flags=0000000010000010
end
item: Install File
Source=${__TCLBASEDIR__}\library\msgcat\msgcat.tcl
- Destination=%MAINDIR%\lib\tcl%VER%\msgcat1.2\msgcat.tcl
+ Destination=%MAINDIR%\lib\tcl%VER%\msgcat1.4\msgcat.tcl
Flags=0000000010000010
end
item: Install File
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 2d871c5..1de7db7 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.132 2003/07/23 15:40:26 das Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.133 2003/10/21 00:23:34 kennykb Exp $
VERSION = @TCL_VERSION@
MAJOR_VERSION = @TCL_MAJOR_VERSION@
@@ -632,7 +632,7 @@ install-libraries: libraries
else true; \
fi; \
done;
- @for i in http2.4 http1.0 opt0.4 encoding msgcat1.3 tcltest2.2; \
+ @for i in http2.4 http1.0 opt0.4 encoding msgcat1.4 tcltest2.2; \
do \
if [ ! -d $(SCRIPT_INSTALL_DIR)/$$i ] ; then \
echo "Making directory $(SCRIPT_INSTALL_DIR)/$$i"; \
@@ -670,10 +670,10 @@ install-libraries: libraries
do \
$(INSTALL_DATA) $$j $(SCRIPT_INSTALL_DIR)/opt0.4; \
done;
- @echo "Installing library msgcat1.3 directory";
+ @echo "Installing library msgcat1.4 directory";
@for j in $(TOP_DIR)/library/msgcat/*.tcl ; \
do \
- $(INSTALL_DATA) $$j $(SCRIPT_INSTALL_DIR)/msgcat1.3; \
+ $(INSTALL_DATA) $$j $(SCRIPT_INSTALL_DIR)/msgcat1.4; \
done;
@echo "Installing library tcltest2.2 directory";
@for j in $(TOP_DIR)/library/tcltest/*.tcl ; \
diff --git a/win/Makefile.in b/win/Makefile.in
index 2c9a98a..a0d5991 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.73 2003/06/25 23:02:11 dkf Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.74 2003/10/21 00:23:34 kennykb Exp $
VERSION = @TCL_VERSION@
@@ -521,7 +521,7 @@ install-libraries: libraries
else true; \
fi; \
done;
- @for i in http1.0 http2.4 opt0.4 encoding msgcat1.3 tcltest2.2; \
+ @for i in http1.0 http2.4 opt0.4 encoding msgcat1.4 tcltest2.2; \
do \
if [ ! -d $(SCRIPT_INSTALL_DIR)/$$i ] ; then \
echo "Making directory $(SCRIPT_INSTALL_DIR)/$$i"; \
@@ -555,10 +555,10 @@ install-libraries: libraries
do \
$(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \
done;
- @echo "Installing library msgcat1.3 directory";
+ @echo "Installing library msgcat1.4 directory";
@for j in $(ROOT_DIR)/library/msgcat/*.tcl; \
do \
- $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/msgcat1.3"; \
+ $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/msgcat1.4"; \
done;
@echo "Installing library tcltest2.2 directory";
@for j in $(ROOT_DIR)/library/tcltest/*.tcl; \
diff --git a/win/makefile.bc b/win/makefile.bc
index c2d0ca7..2457345 100644
--- a/win/makefile.bc
+++ b/win/makefile.bc
@@ -433,10 +433,10 @@ install-libraries:
-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\opt0.4"
-@copy "$(ROOT)\library\opt\optparse.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
-@copy "$(ROOT)\library\opt\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
- @echo installing msgcat1.3
- -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\msgcat1.3"
- -@copy "$(ROOT)\library\msgcat\msgcat.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.3"
- -@copy "$(ROOT)\library\msgcat\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.3"
+ @echo installing msgcat1.4
+ -@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
+ -@copy "$(ROOT)\library\msgcat\msgcat.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
+ -@copy "$(ROOT)\library\msgcat\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
@echo installing tcltest2.2
-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\tcltest2.2"
-@copy "$(ROOT)\library\tcltest\tcltest.tcl" "$(SCRIPT_INSTALL_DIR)\tcltest2.2"
diff --git a/win/makefile.vc b/win/makefile.vc
index 9f6eca9..3628507 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -12,7 +12,7 @@
# Copyright (c) 2001-2002 David Gravereaux.
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: makefile.vc,v 1.111 2003/10/09 00:29:27 patthoyts Exp $
+# RCS: @(#) $Id: makefile.vc,v 1.112 2003/10/21 00:23:34 kennykb Exp $
#------------------------------------------------------------------------------
!if "$(MSVCDIR)" == ""
@@ -773,9 +773,9 @@ install-libraries:
@echo installing opt0.4
@$(CPY) "$(ROOT)\library\opt\*.tcl" \
"$(SCRIPT_INSTALL_DIR)\opt0.4\"
- @echo installing msgcat1.3
+ @echo installing msgcat1.4
@$(CPY) "$(ROOT)\library\msgcat\*.tcl" \
- "$(SCRIPT_INSTALL_DIR)\msgcat1.3\"
+ "$(SCRIPT_INSTALL_DIR)\msgcat1.4\"
@echo installing tcltest2.2
@$(CPY) "$(ROOT)\library\tcltest\*.tcl" \
"$(SCRIPT_INSTALL_DIR)\tcltest2.2\"