| View previous topic :: View next topic |
| Author |
Message |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Oct 30, 2007 10:40 am Post subject: |
|
|
Why don't you use an array?
| Code: |
set langDef(en) {
msg1 {Hello World!}
msg2 {etc...}
}
set langDef(fr) {
msg1 {Bonjour Monde!}
msg2 {etc...}
}
proc setlang {lang} {
array set ::lang $::langDef($lang)
}
|
Test:
| Code: |
% setlang en
% puts $lang(msg1)
Hello World!
% setlang fr
% puts $lang(msg1)
Bonjour Monde!
|
Of course, there are other ways to do this...eg. combining the "message id" and language name to make the element name in your language array (to avoid having to create the array when switching languages - which is better if you need several languages simultaneously)
| Code: | | set lang(en,msg1) "Hello World!" |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Tue Oct 30, 2007 12:59 pm Post subject: |
|
|
Thx user, I think your first solution is the better for me.
I'll next time use msgcat package to do multilanguage tcl, but when I first want to try this way  _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
|
| Back to top |
|
 |
BeBoo Halfop
Joined: 26 Sep 2007 Posts: 42
|
Posted: Fri Nov 02, 2007 10:41 am Post subject: |
|
|
| Changed first post with information. Thanks, CrazyCat!! |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
|
| Back to top |
|
 |
wac Halfop

Joined: 10 Dec 2006 Posts: 80 Location: in my cardboard box
|
Posted: Fri Dec 26, 2008 5:27 am Post subject: |
|
|
the english only one is down and the 'multi-language' one is only does french replies, so as it's not 'multi-language' ... lol _________________ I see j00! |
|
| Back to top |
|
 |
|