What's the standard Tcl way (package?) to localize 'clock'. In any country, I'll get this:
% clock format [clock seconds] Wed Apr 13 17:20:53 +0100 2005
But that 'Wed', 'Apr', are English-only. How do Tcl'ers handle this? - RS often uses this ISO-like format, good for sorting:
% clock format [clock sec] -format %Y-%m-%d,%H:%M:%S 2005-04-13,18:36:18
Ah, yes, but if I want to display a localized date to the user, their own language would be nice...
LES:
proc {mês em português} {} { set Month [ clock format [clock sec] -format "%m" ] set Meses { 0 janeiro fevereiro março abril maio junho julho agosto setembro outubro novembro dezembro } set Mes [ lindex $Meses [ format "%d" $Month ] ] set Month [ clock format [clock sec] -format "%B" ] puts "this is $Month" puts "estamos em $Mes" } {mês em português}
LV Check out Tcl 8.5a1 or newer. Kevin Kenny has been working hard to provide the functionality you desire. See http://tip.tcl.tk/173 for details.
Indeed, Tcl 8.5a1 supports localization of all those languages dependent names for day of week (including abbreviations), month of year, etc.
A simple example is:
package require Tcl 8.5 clock format [clock seconds] -locale de
which would print the current date/time using german words.
KBK Indeed. And Brazilian-Portuguese is already one of the standard locales:
% clock format [clock seconds] -format "%A %d %B %Y" -locale pt_BR Sexta-feira 15 Abril 2005
LES Good. Only note, however, that the name of the month or day of the week should never be capitalized in pt_BR, unless it is the first word of a sentence. I've been told that days of the week are capitalized in Portugal, but I am not really sure of that.