summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-01-10 22:30:24 (GMT)
committersebres <sebres@users.sourceforge.net>2017-01-10 22:30:24 (GMT)
commit94dc5e4e43efe7260594f8d076e20ffdf1559a17 (patch)
treed0b0160f1b83e719ad0ec41239e7b2a98aea16cd /library
parentc52322d40935741e19091f547619c69a831515e1 (diff)
downloadtcl-94dc5e4e43efe7260594f8d076e20ffdf1559a17.zip
tcl-94dc5e4e43efe7260594f8d076e20ffdf1559a17.tar.gz
tcl-94dc5e4e43efe7260594f8d076e20ffdf1559a17.tar.bz2
improve LocalizeFormat, internal caching of localized formats inside msgcat for locale and format objects
smart reference introduced in dict (smart pointer with 0 object reference but increase dict-reference, provide changeable locale dict) code review
Diffstat (limited to 'library')
-rwxr-xr-xlibrary/clock.tcl19
1 files changed, 12 insertions, 7 deletions
diff --git a/library/clock.tcl b/library/clock.tcl
index 4173174..a532c0d 100755
--- a/library/clock.tcl
+++ b/library/clock.tcl
@@ -2365,18 +2365,23 @@ proc ::tcl::clock::LocalizeFormat { locale format {fmtkey {}} } {
dict set LocaleFormats $locale MLST $mlst
}
- # translate:
- set locfmt [string map $mlst $format]
-
- # Save original format as long as possible, because of internal representation (performance)
- if {$locfmt eq $format} {
- set locfmt $format
- }
+ # translate copy of format (don't use format object here, because otherwise
+ # it can lose its internal representation (string map - convert to unicode)
+ set locfmt [string map $mlst [string range " $format" 1 end]]
# cache it:
dict set LocaleFormats $locale $fmtkey $locfmt
}
+ # Save original format as long as possible, because of internal
+ # representation (performance).
+ # Note that in this case such format will be never localized (also
+ # using another locales). To prevent this return a duplicate (but
+ # it may be slower).
+ if {$locfmt eq $format} {
+ set locfmt $format
+ }
+
return $locfmt
}