| View previous topic :: View next topic |
| Author |
Message |
oni- Voice
Joined: 11 Sep 2009 Posts: 1
|
Posted: Thu Apr 15, 2010 2:00 pm Post subject: multi-language support ? |
|
|
i have searched the forum for a method of creating a script with multi-language support, but haven't had any success. the ones i have found all use an array defined somewhere in the script itself, which isn't what i am really looking to do.
what i want to create is a script that will use language files with the naming scheme like: language.en, language.fr, language.xx and so on (filename will change to match the script). i have thought up of a format that would be used for the language files (shown below).
| Code: | # language file en
help Help
clear_database The database has been cleared. |
this is a small example of how it will be formatted. the first word would describe what you are translating and the rest of the string will contain the translation. this will be used to create an array that will be read.
i think the main problem is trying to convert/replace all the text that would be outputted to the channel/user with the language chosen. does anyone have an idea of how i should go about this? or would just trying to use the variables like this be fine:
| Code: | # notice user that the database has been cleared.
output $nick "$lang(clear_database)"; |
all i am trying to find the most efficient way i should go about to write this up. any inputs/opinions ? |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Wed May 05, 2010 9:54 am Post subject: |
|
|
It isn't particularly clear to me what you want. Perhaps this is why there has been no reponse so far.
You could be talking about some technical aspect of Tcl/IRC/Eggdrop. Perhaps the language of the bot's messages (set in the .conf file) or the character set(s) used by Tcl (see encoding) or even the character sets that particular IRC clients are capable of displaying.
Assuming you are not talking technical, I have created a small script to translate words from one of four languages to another. Even if this is a mile away from what you require, at least it might incite further discussion leading to a better explanation of your needs.
The script uses dictionary.txt in the bot's root directory. I created a minimal file for testing purposes as follows :-
table tabelle table tabla
question frage question pregunta
umbrella regenschirm parapluie paraguas
red rot rouge rojo
| Code: |
# languages.tcl
bind PUB n !translate pPubTranslate
proc pPubTranslate {nick uhost hand channel txt} {
set arguments [string trim $txt]
if {[llength [split $arguments]] == 3} {
set languages [lrange [split [string tolower $arguments]] 0 1]
if {[regexp -nocase -- {(en|de|fr|es) (en|de|fr|es)} [join $languages]]} {
set fr [lindex $languages 0]
set to [lindex $languages 1]
if {![string equal $fr $to]} {
set word [lindex [split $arguments] 2]
set fp [open dictionary.txt r]
set data [split [read $fp] \n]
close $fp
set fridx [string map {en 0 de 1 fr 2 es 3} $fr]
set toidx [string map {en 0 de 1 fr 2 es 3} $to]
set found 0
foreach item $data {
if {[string equal -nocase $word [lindex [split $item] $fridx]]} {
set found 1
putserv "PRIVMSG $channel :($fr) $word -> ($to) [lindex [split $item] $toidx]"
break
}
}
if {!$found} {putserv "PRIVMSG $channel :$word not found"}
} else {putserv "PRIVMSG $channel :'from' and 'to' languages must be different"}
} else {putserv "PRIVMSG $channel :'from' and 'to' languages must each be one of en, de, fr, es"}
} else {putserv "PRIVMSG $channel :correct syntax is !translate <from> <to> <word>"}
return 0
}
|
Typical output is as follows :-
[14:32] <@arfer> !translate es de rojo
[14:32] <@osmosis> (es) rojo -> (de) rot
[14:33] <@arfer> !translate en de umbrella
[14:33] <@osmosis> (en) umbrella -> (de) regenschirm
The script is pretty useless as it stands. It would be better to use one of the http translation scripts for such translations. The script only translates single words and not phrases. The script does not account for a word in one language having two or more different meanings, yet are represented in other languages by different words.
Using this as a starting point, what is it that you are asking for? _________________ I must have had nothing to do |
|
| Back to top |
|
 |
|
|
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
|
|