Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tn, ro_MO and ru_MO to msgcat. Make it work on cygwin (backported) Bump msgcat to 1.3.5 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-4-branch |
Files: | files | file ages | folders |
SHA1: |
43a8de67fbf5cf3d29292fed2370c64b |
User & Date: | jan.nijtmans 2012-06-29 11:34:53 |
Context
2012-07-05
| ||
07:45 | protect Tcl_GetIndexFromObjStruct from empty strings in table check-in: f645ace4cc user: jan.nijtmans tags: core-8-4-branch | |
2012-07-02
| ||
16:22 | 1189293 Make '<<' redirects binary safe. Don't use strlen() (or equivalent) to find end of written ... Closed-Leaf check-in: 6fe0dc591c user: dgp tags: bug-1189293 | |
2012-06-29
| ||
11:39 | Add tn, ro_MO and ru_MO to msgcat check-in: 77a676dfce user: jan.nijtmans tags: core-8-5-branch | |
11:34 | Add tn, ro_MO and ru_MO to msgcat. Make it work on cygwin (backported) Bump msgcat to 1.3.5 check-in: 43a8de67fb user: jan.nijtmans tags: core-8-4-branch | |
08:43 | Reinforced the description of the requirement for the tables of names for Tcl_GetIndexFromObj to ind... check-in: dfd2b68795 user: dkf tags: core-8-4-branch | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2012-06-29 Donal K. Fellows <[email protected]> * doc/GetIndex.3: Reinforced the description of the requirement for the tables of names to index over to be static, following posting to tcl-core by Brian Griffin about a bug caused by Tktreectrl not obeying this rule correctly. This does not represent a functionality change, merely a clearer documentation of a long-standing constraint. | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | 2012-06-29 Jan Nijtmans <[email protected]> * library/msgcat/msgcat.tcl: Add tn, ro_MO and ru_MO to msgcat. Make it * library/msgcat/pkgIndex.tcl: work on cygwin. Bump to 1.3.5 2012-06-29 Donal K. Fellows <[email protected]> * doc/GetIndex.3: Reinforced the description of the requirement for the tables of names to index over to be static, following posting to tcl-core by Brian Griffin about a bug caused by Tktreectrl not obeying this rule correctly. This does not represent a functionality change, merely a clearer documentation of a long-standing constraint. |
︙ | ︙ |
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.2\fR .sp | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME msgcat \- Tcl message catalog .SH SYNOPSIS \fBpackage require Tcl 8.2\fR .sp \fBpackage require msgcat 1.3.5\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 |
︙ | ︙ |
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.2 # 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 40 41 | # # 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.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.5 namespace eval msgcat { namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \ mcunknown # Records the current locale as passed to mclocale variable Locale "" # Records the list of locales to search variable Loclist {} # Records the mapping between source strings and translated strings. The # array key is of the form "<locale>,<namespace>,<src>" and the value is # the translated string. array set Msgs {} # Map of language codes used in Windows registry to those of ISO-639 if {[info sharedlibextension] eq ".dll"} { array set WinRegToISO639 { 01 ar 0401 ar_SA 0801 ar_IQ 0c01 ar_EG 1001 ar_LY 1401 ar_DZ 1801 ar_MA 1c01 ar_TN 2001 ar_OM 2401 ar_YE 2801 ar_SY 2c01 ar_JO 3001 ar_LB 3401 ar_KW 3801 ar_AE 3c01 ar_BH 4001 ar_QA 02 bg 0402 bg_BG 03 ca 0403 ca_ES |
︙ | ︙ | |||
61 62 63 64 65 66 67 | 11 ja 0411 ja_JP 12 ko 0412 ko_KR 13 nl 0413 nl_NL 0813 nl_BE 14 no 0414 no_NO 0814 nn_NO 15 pl 0415 pl_PL 16 pt 0416 pt_BR 0816 pt_PT 17 rm 0417 rm_CH | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 11 ja 0411 ja_JP 12 ko 0412 ko_KR 13 nl 0413 nl_NL 0813 nl_BE 14 no 0414 no_NO 0814 nn_NO 15 pl 0415 pl_PL 16 pt 0416 pt_BR 0816 pt_PT 17 rm 0417 rm_CH 18 ro 0418 ro_RO 0818 ro_MO 19 ru 0819 ru_MO 1a hr 041a hr_HR 081a sr_YU 0c1a sr_YU@cyrillic 1b sk 041b sk_SK 1c sq 041c sq_AL 1d sv 041d sv_SE 081d sv_FI 1e th 041e th_TH 1f tr 041f tr_TR 20 ur 0420 ur_PK 0820 ur_IN |
︙ | ︙ | |||
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 2b hy 042b hy_AM 2c az 042c az_AZ@latin 082c az_AZ@cyrillic 2d eu 2e wen 042e wen_DE 2f mk 042f mk_MK 30 bnt 0430 bnt_TZ 31 ts 0431 ts_ZA 33 ven 0433 ven_ZA 34 xh 0434 xh_ZA 35 zu 0435 zu_ZA 36 af 0436 af_ZA 37 ka 0437 ka_GE 38 fo 0438 fo_FO 39 hi 0439 hi_IN | > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 2b hy 042b hy_AM 2c az 042c az_AZ@latin 082c az_AZ@cyrillic 2d eu 2e wen 042e wen_DE 2f mk 042f mk_MK 30 bnt 0430 bnt_TZ 31 ts 0431 ts_ZA 32 tn 33 ven 0433 ven_ZA 34 xh 0434 xh_ZA 35 zu 0435 zu_ZA 36 af 0436 af_ZA 37 ka 0437 ka_GE 38 fo 0438 fo_FO 39 hi 0439 hi_IN |
︙ | ︙ | |||
170 171 172 173 174 175 176 | # string. # # Arguments: # src The string to translate. # args Args to pass to the format command # # Results: | | | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | # string. # # Arguments: # src The string to translate. # args Args to pass to the format command # # Results: # Returns the translated string. Propagates errors thrown by the # format command. proc msgcat::mc {src args} { # Check for the src in each namespace starting from the local and # ending in the global. variable Msgs variable Loclist variable Locale set ns [uplevel 1 [list ::namespace current]] while {$ns != ""} { foreach loc $Loclist { if {[info exists Msgs($loc,$ns,$src)]} { if {[llength $args] == 0} { return $Msgs($loc,$ns,$src) } else { return [uplevel 1 \ |
︙ | ︙ | |||
274 275 276 277 278 279 280 | set x 0 foreach p [mcpreferences] { set langfile [file join $langdir $p.msg] if {[file exists $langfile]} { incr x set fid [open $langfile "r"] fconfigure $fid -encoding utf-8 | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | set x 0 foreach p [mcpreferences] { set langfile [file join $langdir $p.msg] if {[file exists $langfile]} { incr x set fid [open $langfile "r"] fconfigure $fid -encoding utf-8 uplevel 1 [read $fid] close $fid } } return $x } # msgcat::mcset -- |
︙ | ︙ | |||
297 298 299 300 301 302 303 | # # Results: # Returns the new locale. proc msgcat::mcset {locale src {dest ""}} { variable Msgs if {[llength [info level 0]] == 3} { ;# dest not specified | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | # # Results: # Returns the new locale. proc msgcat::mcset {locale src {dest ""}} { variable Msgs if {[llength [info level 0]] == 3} { ;# dest not specified set dest $src } set ns [uplevel 1 [list ::namespace current]] set Msgs([string tolower $locale],$ns,$src) $dest return $dest } |
︙ | ︙ | |||
324 325 326 327 328 329 330 | proc msgcat::mcmset {locale pairs } { variable Msgs set length [llength $pairs] if {$length % 2} { error {bad translation list: should be "mcmset locale {src dest ...}"} } | | | | | | | 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 | proc msgcat::mcmset {locale pairs } { variable Msgs set length [llength $pairs] if {$length % 2} { error {bad translation list: should be "mcmset locale {src dest ...}"} } set locale [string tolower $locale] set ns [uplevel 1 [list ::namespace current]] foreach {src dest} $pairs { set Msgs($locale,$ns,$src) $dest } return $length } # 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 # 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 |
︙ | ︙ | |||
362 363 364 365 366 367 368 | } else { return $src } } # msgcat::mcmax -- # | | | | | | | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | } else { return $src } } # msgcat::mcmax -- # # Calculates the maximum length of the translated strings of the given # list. # # Arguments: # args strings to translate. # # Results: # Returns the length of the longest translated string. proc msgcat::mcmax {args} { set max 0 foreach string $args { set translated [uplevel 1 [list [namespace origin mc] $string]] set len [string length $translated] if {$len>$max} { set max $len } } return $max } # Convert the locale values stored in environment variables to a form # suitable for passing to [mclocale] proc msgcat::ConvertLocale {value} { |
︙ | ︙ | |||
414 415 416 417 418 419 420 421 422 423 424 | append ret _$modifier } return $ret } # Initialize the default locale proc msgcat::Init {} { # # set default locale, try to get from environment # foreach varName {LC_ALL LC_MESSAGES LANG} { | > > | | | | | | | | | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | append ret _$modifier } return $ret } # Initialize the default locale proc msgcat::Init {} { global env # # set default locale, try to get from environment # foreach varName {LC_ALL LC_MESSAGES LANG} { if {[info exists env($varName)] && ![string equal "" $env($varName)]} { if {![catch {mclocale [ConvertLocale $env($varName)]}]} { return } } } # # On Darwin, fallback to current CFLocale identifier if available. # if {[string equal $::tcl_platform(os) Darwin] && [string equal $::tcl_platform(platform) unix] && [info exists ::tcl::mac::locale] && ![string equal $::tcl::mac::locale ""]} { if {![catch {mclocale [ConvertLocale $::tcl::mac::locale]}]} { return } } # # The rest of this routine is special processing for Windows; # all other platforms, get out now. # if {![string equal [info sharedlibextension] .dll]} { mclocale C return } # # On Windows or Cygwin, try to set locale depending on registry # settings, or fall back on locale of "C". # set key {HKEY_CURRENT_USER\Control Panel\International} if {[catch {package require registry}] \ || [catch {registry get $key "locale"} locale]} { mclocale C return } # # Keep trying to match against smaller and smaller suffixes # of the registry value, since the latter hexadigits appear # to determine general language and earlier hexadigits determine # more precise information, such as territory. For example, # 0409 - English - United States # 0809 - English - United Kingdom # Add more translations to the WinRegToISO639 array above. # variable WinRegToISO639 set locale [string tolower $locale] while {[string length $locale]} { if {![catch {mclocale [ConvertLocale $WinRegToISO639($locale)]}]} { return } set locale [string range $locale 1 end] } # # No translation known. Fall back on "C" locale # mclocale C } msgcat::Init |
Changes to library/msgcat/pkgIndex.tcl.
1 | if {![package vsatisfies [package provide Tcl] 8.2]} {return} | | | 1 2 | if {![package vsatisfies [package provide Tcl] 8.2]} {return} package ifneeded msgcat 1.3.5 [list source [file join $dir msgcat.tcl]] |
Changes to tests/msgcat.test.
︙ | ︙ | |||
13 14 15 16 17 18 19 | # message catalogs for locales foo, foo_BAR, and foo_BAR_baz. package require Tcl 8.2 if {[catch {package require tcltest 2}]} { puts stderr "Skipping tests in [info script]. tcltest 2 required." return } | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # message catalogs for locales foo, foo_BAR, and foo_BAR_baz. 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.5}]} { puts stderr "Skipping tests in [info script]. No msgcat 1.3.5 found to test." return } namespace eval ::msgcat::test { namespace import ::msgcat::* namespace import ::tcltest::test namespace import ::tcltest::cleanupTests |
︙ | ︙ | |||
45 46 47 48 49 50 51 | } variable envVars {LC_ALL LC_MESSAGES LANG} variable count 0 variable body variable result variable setVars | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | } variable envVars {LC_ALL LC_MESSAGES LANG} variable count 0 variable body variable result variable setVars foreach setVars [PowerSet $envVars] { set result [string tolower [lindex $setVars 0]] if {[string length $result] == 0} { if {[info exists ::tcl::mac::locale]} { set result [string tolower $::tcl::mac::locale] } else { set result c } |
︙ | ︙ | |||
79 80 81 82 83 84 85 | catch {unset ::env($var)} catch {set ::env($var) [set [namespace current]::$var]} } } -body {i eval msgcat::mclocale} -result $result incr count } catch {unset result} | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | catch {unset ::env($var)} catch {set ::env($var) [set [namespace current]::$var]} } } -body {i eval msgcat::mclocale} -result $result incr count } catch {unset result} # Could add tests of initialization from Windows registry here. # Use a fake registry package. # Tests msgcat-1.*: [mclocale], [mcpreferences] test msgcat-1.3 {mclocale set, single element} -setup { variable locale [mclocale] |
︙ | ︙ | |||
468 469 470 471 472 473 474 | removeFile [string tolower [file join msgdir $loc.msg]] } removeDirectory msgdir # Tests msgcat-6.*: [mcset], [mc] namespace inheritance # # Test mcset and mc, ensuring that resolution for messages | | | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | removeFile [string tolower [file join msgdir $loc.msg]] } removeDirectory msgdir # Tests msgcat-6.*: [mcset], [mc] namespace inheritance # # Test mcset and mc, ensuring that resolution for messages # proceeds from the current ns to its parent and so on to the # global ns. # # Do this for the 12 permutations of # locales: foo # namespaces: foo foo::bar foo::bar::baz # strings: {ov1 ov2 ov3 ov4} # namespace ::foo defines ov1, ov2, ov3 |
︙ | ︙ | |||
512 513 514 515 516 517 518 | namespace eval bar { ::msgcat::mcset foo ov2 ov2_foo_bar ::msgcat::mcset foo ov3 ov3_foo_bar namespace eval baz { ::msgcat::mcset foo ov3 "ov3_foo_bar_baz" } } | | | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | namespace eval bar { ::msgcat::mcset foo ov2 ov2_foo_bar ::msgcat::mcset foo ov3 ov3_foo_bar namespace eval baz { ::msgcat::mcset foo ov3 "ov3_foo_bar_baz" } } } variable locale [mclocale] mclocale foo } -cleanup { mclocale $locale namespace delete foo } -body { |
︙ | ︙ |