egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to Replace WEEKDAY to another Language in tcl script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Foxman
Voice


Joined: 10 Jan 2007
Posts: 9
Location: Delft, Zuid-Holland, The Netherlands

PostPosted: Thu Mar 08, 2007 1:21 pm    Post subject: How to Replace WEEKDAY to another Language in tcl script Reply with quote

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:

Code:
[strftime %A $lut]


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
View user's profile Send private message Visit poster's website
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Mar 08, 2007 3:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Mar 08, 2007 3:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
Foxman
Voice


Joined: 10 Jan 2007
Posts: 9
Location: Delft, Zuid-Holland, The Netherlands

PostPosted: Thu Mar 08, 2007 3:43 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Mar 08, 2007 7:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Foxman
Voice


Joined: 10 Jan 2007
Posts: 9
Location: Delft, Zuid-Holland, The Netherlands

PostPosted: Thu Mar 08, 2007 7:24 pm    Post subject: Reply with quote

Thanks a lot all, it worked! now i can do the same for MONTHS. %B

you guy's are great!
Back to top
View user's profile Send private message Visit poster's website
Torrevado
Op


Joined: 02 Aug 2006
Posts: 101

PostPosted: Sun Mar 11, 2007 1:27 pm    Post subject: Reply with quote

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) Rolling Eyes
Back to top
View user's profile Send private message
Foxman
Voice


Joined: 10 Jan 2007
Posts: 9
Location: Delft, Zuid-Holland, The Netherlands

PostPosted: Sun Mar 11, 2007 2:05 pm    Post subject: Reply with quote

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 Smile

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 Razz)
Back to top
View user's profile Send private message Visit poster's website
Torrevado
Op


Joined: 02 Aug 2006
Posts: 101

PostPosted: Mon Mar 12, 2007 2:54 pm    Post subject: Reply with quote

Thanks Foxman, it works Wink
Back to top
View user's profile Send private message
Foxman
Voice


Joined: 10 Jan 2007
Posts: 9
Location: Delft, Zuid-Holland, The Netherlands

PostPosted: Fri Sep 07, 2007 12:55 pm    Post subject: Reply with quote

About the month translation [lindex.. works only for 8 months Wink
i'll try the [string Map... now

See yah Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber