| View previous topic :: View next topic |
| Author |
Message |
Foxman Voice

Joined: 10 Jan 2007 Posts: 9 Location: Delft, Zuid-Holland, The Netherlands
|
Posted: Thu Mar 08, 2007 1:21 pm Post subject: How to Replace WEEKDAY to another Language in tcl script |
|
|
I've translated a script to Dutch (BogusTrivia) all good...
But i would also like to tranlate the Weekday's in the script the day's are called like this:
This will show: sunday, monday, tuesday, wednesday, thursday, friday or saturday
I thought doing something like:
| Code: | [TDoDay [strftime %A $lut]]
proc TDoDay {} {
Sunday { return Zondag }
Monday { return Maandag }
Tuesday { return Dinsdag }
Wednesday { return Woensdag }
Thursday { return Donderdag }
Friday { return Vrijdag }
Saturday { return Zaterdag }
} |
would do the thrick, but it doesn't work so far.
Does anyone have a suggestion on how to make this work?
Thank you |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Mar 08, 2007 3:16 pm Post subject: |
|
|
| Code: | set nameOfDay [string map {
Sunday Zondag
Monday Maandag
Tuesday Dinsdag
Wednesday Woensdag
Thursday Donderdag
Friday Vrijdag
Saturday Zaterdag
} [strftime %A $lut]] |
or use %w to get the day of week as an integer (0-6, 0 being sunday):
| Code: | | set nameOfDay [lindex {Zondag Maandag Dinsdag Woensdag Donderdag Vrijdag Zaterdag} [clock format $lut -format %w]] |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Thu Mar 08, 2007 3:20 pm Post subject: |
|
|
Use lindex and string map, assuming your strftime returns something like:
Thursday, Month Day Year Time
You can do:
set TDoDay [string map {Monday Maandag Tuesday Dinsdag (and so on)} [lindex [split [strftime %A $lut] ,] 0]]
Check the manpage for 'string' to see how to use string map.
Note the comma in the [split] command, if your strftime uses a comma after the day of week, otherwise [split [strftime %A $lut]] should do the trick. The way I did the line above stacks all of the commands into 1 line. |
|
| Back to top |
|
 |
Foxman Voice

Joined: 10 Jan 2007 Posts: 9 Location: Delft, Zuid-Holland, The Netherlands
|
Posted: Thu Mar 08, 2007 3:43 pm Post subject: |
|
|
I take it:
If I would use:
| Code: | set nameOfDay [string map {
Sunday Zondag
Monday Maandag
Tuesday Dinsdag
Wednesday Woensdag
Thursday Donderdag
Friday Vrijdag
Saturday Zaterdag
} [strftime %A $lut]] |
I should replace
[strftime %A $lut] for $nameOfDay
in the script?
The actual line in the script is:
| Code: | | set sholine "$tclr(-d10) [string toupper [strftime %A $lut]]S Top 10 - " |
Thanks for the fast help again  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Mar 08, 2007 7:19 pm Post subject: |
|
|
| Quote: | .tcl set lut [unixtime]
Tcl: 1173395909
.tcl set nameOfDay [string map {
Sunday Zondag
Monday Maandag
Tuesday Dinsdag
Wednesday Woensdag
Thursday Donderdag
Friday Vrijdag
Saturday Zaterdag} [strftime %A $lut]]
Tcl: Vrijdag
.tcl set nameOfDay [lindex {Zondag Maandag Dinsdag Woensdag Donderdag Vrijdag Zaterdag} [clock format $lut -format %w]]
Tcl: Vrijdag |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Foxman Voice

Joined: 10 Jan 2007 Posts: 9 Location: Delft, Zuid-Holland, The Netherlands
|
Posted: Thu Mar 08, 2007 7:24 pm Post subject: |
|
|
Thanks a lot all, it worked! now i can do the same for MONTHS. %B
you guy's are great! |
|
| Back to top |
|
 |
Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Sun Mar 11, 2007 1:27 pm Post subject: |
|
|
Hi,
I tried to do the same in spanish, so:
| Quote: | .tcl set lut [unixtime]
Tcl: 1173633454
.tcl set nameOfDay [lindex {Domingo Lunes Martes Miercoles Jueves Viernes Sabado} [clock format $lut -format %w]]
Tcl: Domingo
.tcl set nameOfMonth [lindex {Diciembre Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre} [clock format $lut -format %m]]
Tcl: Marzo |
Nothing changed in the script, it still displays weekdays and months in English.
I didn't change anything in the script, dunno what should I add exactly, and where... I just made what I wrote above (in the console)  |
|
| Back to top |
|
 |
Foxman Voice

Joined: 10 Jan 2007 Posts: 9 Location: Delft, Zuid-Holland, The Netherlands
|
Posted: Sun Mar 11, 2007 2:05 pm Post subject: |
|
|
Hi Fly,
You have to look for the line
| Code: | | set sholine "$tclr(-d10) [string toupper [strftime %A $lut]]S Top 10 - " |
And add the new code/change old code like this
| Code: |
set nameOfDay [lindex {Domingo Lunes Martes Miercoles Jueves Viernes Sabado} [clock format $lut -format %w]]
set sholine "$tclr(-d10) [string toupper $nameOfDay]S Top 10 - "
if {$t2(history)=="1" && $lcnt>"10"} { set lcnt 10 }
if {$t2(history)>"1" && $lcnt>"11"} {
if {$lcnt>"20"} { set lcnt 20 }
set sholin2 "$tclr(-d10) [string toupper $nameOfDay]S Top 11-20: - " } |
Then it will work, and you can do the same for the Months
Further in the script you have to do it again for [strftime %A $dut], [strftime %B $dut]
Good luck
ps: you have to do it like this because $lut does only exist in that part of the script, and it shouldn't be unixtime (that is how i understand it. And it works for me ) |
|
| Back to top |
|
 |
Torrevado Op
Joined: 02 Aug 2006 Posts: 101
|
Posted: Mon Mar 12, 2007 2:54 pm Post subject: |
|
|
Thanks Foxman, it works  |
|
| Back to top |
|
 |
Foxman Voice

Joined: 10 Jan 2007 Posts: 9 Location: Delft, Zuid-Holland, The Netherlands
|
Posted: Fri Sep 07, 2007 12:55 pm Post subject: |
|
|
About the month translation [lindex.. works only for 8 months
i'll try the [string Map... now
See yah  |
|
| Back to top |
|
 |
|