Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Commit of Harald Oehlmann's TIP 404 patch without TIP 399 pieces and with some added documentation. No tests for new functionality yet. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tip-404 |
Files: | files | file ages | folders |
SHA1: |
b7c45985010e1223af192ce9680d30aa |
User & Date: | dkf 2012-08-27 17:24:55 |
Context
2012-09-07
| ||
16:30 | Reentrant mcfl(m)set, test, recommenting mcflset for mc files Closed-Leaf check-in: 8bb57fb08b user: oehhar tags: mistake | |
15:32 | Reentrant mcfl(m)set command, test, document mcflset as recommended for message files check-in: 62aa37bb59 user: oehhar tags: tip-404 | |
2012-08-28
| ||
14:15 | Added mcconfig -mcfilelocale, as TIP-specified. check-in: 674aa977f0 user: dkf tags: tip-404 | |
2012-08-27
| ||
17:24 | Commit of Harald Oehlmann's TIP 404 patch without TIP 399 pieces and with some added documentation. ... check-in: b7c4598501 user: dkf tags: tip-404 | |
17:12 | Followup to [6325d5dbeac6f91d28d6]. dlerror() may return NULL. Fixed the code which wasn't prepared ... check-in: d17e59a33e user: andreask tags: trunk | |
Changes
Changes to doc/msgcat.n.
︙ | ︙ | |||
9 10 11 12 13 14 15 | .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME msgcat \- Tcl message catalog .SH SYNOPSIS \fBpackage require Tcl 8.5\fR .sp | | > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME msgcat \- Tcl message catalog .SH SYNOPSIS \fBpackage require Tcl 8.5\fR .sp \fBpackage require msgcat 1.5.0\fR .sp \fB::msgcat::mc \fIsrc-string\fR ?\fIarg arg ...\fR? .sp \fB::msgcat::mcmax ?\fIsrc-string src-string ...\fR? .sp \fB::msgcat::mclocale \fR?\fInewLocale\fR? .sp \fB::msgcat::mcpreferences\fR .sp \fB::msgcat::mcload \fIdirname\fR .sp \fB::msgcat::mcset \fIlocale src-string \fR?\fItranslate-string\fR? .sp \fB::msgcat::mcmset \fIlocale src-trans-list\fR .sp .VS "TIP 404" \fB::msgcat::mcflset \fIsrc-string \fR?\fItranslate-string\fR? .sp \fB::msgcat::mcflmset \fIsrc-trans-list\fR .VE "TIP 404" .sp \fB::msgcat::mcunknown \fIlocale src-string\fR .BE .SH DESCRIPTION .PP The \fBmsgcat\fR package provides a set of functions that can be used to manage multi-lingual user interfaces. |
︙ | ︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | \fIsrc-trans-list\fR in the specified \fIlocale\fR and the current namespace. \fIsrc-trans-list\fR must have an even number of elements and is in the form {\fIsrc-string translate-string\fR ?\fIsrc-string translate-string ...\fR?} \fB::msgcat::mcmset\fR can be significantly faster than multiple invocations of \fB::msgcat::mcset\fR. The function returns the number of translations set. .TP \fB::msgcat::mcunknown \fIlocale src-string\fR . This routine is called by \fB::msgcat::mc\fR in the case when 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 | > > > > > > > > > > > > > > > > > > > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | \fIsrc-trans-list\fR in the specified \fIlocale\fR and the current namespace. \fIsrc-trans-list\fR must have an even number of elements and is in the form {\fIsrc-string translate-string\fR ?\fIsrc-string translate-string ...\fR?} \fB::msgcat::mcmset\fR can be significantly faster than multiple invocations of \fB::msgcat::mcset\fR. The function returns the number of translations set. .TP \fB::msgcat::mcflset \fIsrc-string \fR?\fItranslate-string\fR? .VS "TIP 404" Sets the translation for \fIsrc-string\fR to \fItranslate-string\fR in the the current namespace for the locale implied by the name of the message catalog being loaded via \fB::msgcat::mcload\fR. If \fItranslate-string\fR is not specified, \fIsrc-string\fR is used for both. The function returns \fItranslate-string\fR. .VE "TIP 404" .TP \fB::msgcat::mcflmset \fIsrc-trans-list\fR .VS "TIP 404" Sets the translation for multiple source strings in \fIsrc-trans-list\fR in the current namespace for the locale implied by the name of the message catalog being loaded via \fB::msgcat::mcload\fR. \fIsrc-trans-list\fR must have an even number of elements and is in the form {\fIsrc-string translate-string\fR ?\fIsrc-string translate-string ...\fR?} \fB::msgcat::mcmset\fR can be significantly faster than multiple invocations of \fB::msgcat::mcset\fR. The function returns the number of translations set. .VE "TIP 404" .TP \fB::msgcat::mcunknown \fIlocale src-string\fR . This routine is called by \fB::msgcat::mc\fR in the case when 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 |
︙ | ︙ |
Changes to library/msgcat/msgcat.tcl.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. 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. | | | > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. 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.5.0 namespace eval msgcat { namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \ mcunknown mcflset mcflmset # Records the current locale as passed to mclocale variable Locale "" # Records the list of locales to search variable Loclist {} # Records the locale of the currently sourced message catalogue file; this # would be problematic if anyone were to recursively load a message # catalog for a different locale from inside a catalog, but that's not a # case that we really need to worry about. variable FileLocale # Records the mapping between source strings and translated strings. The # dict key is of the form "<locale> <namespace> <src>", where locale and # namespace should be themselves dict values and the value is # the translated string. variable Msgs [dict create] |
︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | # Arguments: # langdir The directory to search. # # Results: # Returns the number of message catalogs that were loaded. 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 uplevel 1 [list ::source -encoding utf-8 $langfile] } } return $x } # msgcat::mcset -- # | > > > > > > | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | # Arguments: # langdir The directory to search. # # Results: # Returns the number of message catalogs that were loaded. proc msgcat::mcload {langdir} { variable FileLocale 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 set FileLocale [string tolower [file tail [file rootname $langfile]]] if {"root" eq $FileLocale} { set FileLocale "" } uplevel 1 [list ::source -encoding utf-8 $langfile] unset FileLocale } } return $x } # msgcat::mcset -- # |
︙ | ︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 | set ns [uplevel 1 [list ::namespace current]] set locale [string tolower $locale] dict set Msgs $locale $ns $src $dest return $dest } # msgcat::mcmset -- # # Set the translation for multiple strings in a specified locale. # # Arguments: # locale The locale to use. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | set ns [uplevel 1 [list ::namespace current]] set locale [string tolower $locale] dict set Msgs $locale $ns $src $dest return $dest } # msgcat::mcflset -- # # Set the translation for a given string in the current file locale. # # Arguments: # src The source string. # dest (Optional) The translated string. If omitted, # the source string is used. # # Results: # Returns the new locale. proc msgcat::mcflset {src {dest ""}} { variable FileLocale variable Msgs if {![info exists FileLocale]} { return -code error \ "must only be used inside a message catalog loaded with ::msgcat::mcload" } if {[llength [info level 0]] == 2} { ;# dest not specified set dest $src } set ns [uplevel 1 [list ::namespace current]] dict set Msgs $FileLocale $ns $src $dest return $dest } # msgcat::mcmset -- # # Set the translation for multiple strings in a specified locale. # # Arguments: # locale The locale to use. |
︙ | ︙ | |||
341 342 343 344 345 346 347 | set locale [string tolower $locale] set ns [uplevel 1 [list ::namespace current]] foreach {src dest} $pairs { dict set Msgs $locale $ns $src $dest } | > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | set locale [string tolower $locale] set ns [uplevel 1 [list ::namespace current]] foreach {src dest} $pairs { dict set Msgs $locale $ns $src $dest } return [expr {$length / 2}] } # msgcat::mcflmset -- # # Set the translation for multiple strings in the mc file locale. # # Arguments: # pairs One or more src/dest pairs (must be even length) # # Results: # Returns the number of pairs processed proc msgcat::mcflmset {pairs} { variable FileLocale variable Msgs if {![info exists FileLocale]} { return -code error \ "must only be used inside a message catalog loaded with ::msgcat::mcload" } set length [llength $pairs] if {$length % 2} { return -code error "bad translation list:\ should be \"[lindex [info level 0] 0] locale {src dest ...}\"" } set ns [uplevel 1 [list ::namespace current]] foreach {src dest} $pairs { dict set Msgs $FileLocale $ns $src $dest } return [expr {$length / 2}] } # msgcat::mcunknown -- # # This routine is called by msgcat::mc if a translation cannot # be found for a string. This routine is intended to be replaced # by an application specific routine for error reporting |
︙ | ︙ |
Changes to library/msgcat/pkgIndex.tcl.
1 | if {![package vsatisfies [package provide Tcl] 8.5]} {return} | | | 1 2 | if {![package vsatisfies [package provide Tcl] 8.5]} {return} package ifneeded msgcat 1.5.0 [list source [file join $dir msgcat.tcl]] |