Difference between revisions of "User talk:Perry Mizin"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 45: Line 45:


----
----
Estoy probando el comprobador de deletreo de Yahoo aunque la verdad es que no estoy teniendo buenos resultados, parece que Google es mucho más rapido y necesito corregir antes de traducir. También estoy intentando solucionar el error que aparece con el símbolo (apostrofe) ´ en las frases con genitivo sajon traducidas al inglés y tampoco doy con la tecla... Ya que esto me está dando muchos dolores de cabeza quizás deje el proyecto en standby hasta después de navidades.
I am testing the Yahoo´s spell checker althought to be honest I´m not having good success, it seems Google is much faster and I need to correct before translate. Also I am triying to fix the error showed in the phrases translated to English with the saxons genitive apostrophe ´ and still triying and triying. As this is driving me nuts, maybe I will leave the project in standby until new year.
ESTO ES EL TRADUCTOR "un lío" por ahora... Necesito rehacer algunas cosas
ESTO ES EL TRADUCTOR "un lío" por ahora... Necesito rehacer algunas cosas


Line 51: Line 60:


<lsl>
<lsl>
//Personal Translator
//Personal Translator (Mod made in Perry Mizin)
//Universal Translator (Mods made in Perry Mizin)
//Universal Translator
//Version 1.9.0
//Version 1.9.0
//November 12, 2009
//November 12, 2009
//LSL Script copyright 2006-2009 by Hank Ramos
//LSL Script copyright 2006-2009 by Hank Ramos
//Web Server Services powered by Google
//Translation Web Services powered by Google
//Spell Checker Web Services powered by Yahoo
//Variables
//Variables
list requestedTranslations;
list requestedTranslations;
list tempDetections;
list tempDetections;
list agentsInTranslation;
list agentsInTranslation;
list spellchecks;
list corrections;
integer M = 1;
integer M = 1;
integer listenID;
integer listenID;
Line 70: Line 82:
integer isInitialized = FALSE;
integer isInitialized = FALSE;
string  options;
string  options;
string tempcorrection;
key tempValue;
key tempValue;
//Functions
//Functions
integer contains(string haystack, string needle) // http://wiki.secondlife.com/wiki/llSubStringIndex
integer contains(string haystack, string needle) // http://wiki.secondlife.com/wiki/llSubStringIndex
{
{
return ~llSubStringIndex(haystack, needle);
    return ~llSubStringIndex(haystack, needle);
}
}
 
sendIM(key imid, string imstr)
sendIM(key imid, string imstr)
{ // llInstantMessage(key id , string message) causes the script to sleep for 2 seconds
{
if (showTranslation == TRUE)
    // llInstantMessage(key id , string message) causes the script to sleep for 2 seconds
{
    if (llGetAgentSize(imid) == ZERO_VECTOR)
if (imid != llGetOwner())
    { }
{
    else
llOwnerSay(imstr + " @" + llKey2Name(imid));  //llOwnerSay(string message) has no delay
    {
}
        if (imid != llGetOwner())
}
        {
if (M == 8)
            llOwnerSay(imstr + " @" + llKey2Name(imid));  //llOwnerSay(string message) has no delay
{
        }
llMessageLinked(LINK_THIS, 2334420, imstr, imid);
    }
M = 1;
    if (M == 8)
}
    {
else if (M == 7)
        llMessageLinked(LINK_THIS, 2334420, imstr, imid);
{
        M = 1;
llMessageLinked(LINK_THIS, 2334430, imstr, imid);
    }
M = 8;
    else if (M == 7)
}
    {
else if (M == 6)
        llMessageLinked(LINK_THIS, 2334430, imstr, imid);
{
        M = 8;
llMessageLinked(LINK_THIS, 2334440, imstr, imid);
    }
M = 7;
    else if (M == 6)
}
    {
else if (M == 5)
        llMessageLinked(LINK_THIS, 2334440, imstr, imid);
{
        M = 7;
llMessageLinked(LINK_THIS, 2334450, imstr, imid);
    }
M = 6;
    else if (M == 5)
}
    {
else if (M == 4)
        llMessageLinked(LINK_THIS, 2334450, imstr, imid);
{
        M = 6;
llMessageLinked(LINK_THIS, 2334460, imstr, imid);
    }
M = 5;
    else if (M == 4)
}
    {
else if (M == 3)
        llMessageLinked(LINK_THIS, 2334460, imstr, imid);
{
        M = 5;
llMessageLinked(LINK_THIS, 2334470, imstr, imid);
    }
M = 4;
    else if (M == 3)
}
    {
else if (M == 2)
        llMessageLinked(LINK_THIS, 2334470, imstr, imid);
{
        M = 4;
llMessageLinked(LINK_THIS, 2334480, imstr, imid);
    }
M = 3;
    else if (M == 2)
}
    {
else if (M == 1)
        llMessageLinked(LINK_THIS, 2334480, imstr, imid);
{
        M = 3;
llMessageLinked(LINK_THIS, 2334490, imstr, imid);
    }
M = 2;
    else if (M == 1)
}
    {
        llMessageLinked(LINK_THIS, 2334490, imstr, imid);
        M = 2;
    }
}
}
 
detectLanguage(string dtcmsg, key dtckey)
DetectLanguage(string dtcmsg, key dtcid)
{
{
tempValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=" + llEscapeURL(dtcmsg), [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], " ");
    tempValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=" + llEscapeURL(dtcmsg), [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], " ");
if (tempValue != NULL_KEY)
    if (tempValue != NULL_KEY)
{
    {
tempDetections = (tempDetections=[]) + tempDetections + [tempValue, dtckey];
        tempDetections = (tempDetections=[]) + tempDetections + [tempValue, dtcid];
}
    }
}
}
 
CheckSpell(integer splnum, string splmsg)
{
    key spellValue;
    spellValue = llHTTPRequest("http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?appid=DNPjiabV34EOgXQ3kAu6.d7kf6v.JUGCn1bFUcSTFMSGCyCy_ALzbepYstlI7DrOGP0-&query=" + splmsg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], "");
    if (spellValue != NULL_KEY)
    {    //Translation
        spellchecks = (spellchecks=[]) + spellchecks + [spellValue, splnum];
    }
}
 
Translate(integer chkn, string chkmsg, list chkli)
Translate(integer chkn, string chkmsg, list chkli)
{
{
key returnValue;
    key returnValue;
returnValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" + chkmsg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], "");
    returnValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" + chkmsg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], "");
if (returnValue != NULL_KEY)
    if (returnValue != NULL_KEY)
{ //Translation
    {   //Translation
requestedTranslations = (requestedTranslations=[]) + requestedTranslations + [returnValue, llList2CSV(chkli)];
        requestedTranslations = (requestedTranslations=[]) + requestedTranslations + [returnValue, llList2CSV(chkli)];
}
    }
else
    else
{
    {
llSleep(5.0); //Something has gone horribly wrong, sleep 5 seconds to clear throttle
        llSleep(25.0); //Something has gone horribly wrong, sleep 25 seconds to clear throttle
}
    }
}
}
 
string checkLanguage(string chklantmpStr)
string checkLanguage(string chklantmpStr)
{
{
if (chklantmpStr == "")
    if (chklantmpStr == "")
{
    {
chklantmpStr = "en";
        chklantmpStr = "en";
}
    }
else if (chklantmpStr == "und")
    else if (chklantmpStr == "und")
{
    {
chklantmpStr = "el";
        chklantmpStr = "el";
}
    }
if (llGetSubString(chklantmpStr, 0, 1) == "zh")
    if (llGetSubString(chklantmpStr, 0, 1) == "zh")
{
    {
chklantmpStr = "zh-CN";
        chklantmpStr = "zh-CN";
}
    }
else
    else
{
    {
chklantmpStr = llGetSubString(chklantmpStr, 0, 1);
        chklantmpStr = llGetSubString(chklantmpStr, 0, 1);
}
    }
return chklantmpStr;
    return chklantmpStr;
}
}
 
addAgent(key avid, string avlan, integer chklan)
addAgent(key avid, string avlan, integer chklan)
{
{
integer avliPos;
    integer avliPos;
integer idNum;
    integer idNum;
if (~llListFindList(agentsInTranslation, (list)avid))
    if (~llListFindList(agentsInTranslation, (list)avid))
{
    {
avliPos = llListFindList(agentsInTranslation, (list)avid);
        avliPos = llListFindList(agentsInTranslation, (list)avid);
agentsInTranslation = llListReplaceList(agentsInTranslation, [avlan, chklan], avliPos + 1, avliPos + 2);
        agentsInTranslation = llListReplaceList(agentsInTranslation, [avlan, avlan, chklan], avliPos + 1, avliPos + 3);
}
    }
else
    else
{
    {
@at;
        @at;
idNum = llRound(llFrand(2000000)) + 1;
        idNum = llRound(llFrand(2000000)) + 1;
if(~llListFindList(agentsInTranslation, (list)idNum))
        if(~llListFindList(agentsInTranslation, (list)idNum))
{
        {
jump at;
            jump at;
}
        }
agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [avid, avlan, chklan, idNum];
        agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [avid, avlan, avlan, chklan, idNum];
// llMessageLinked(LINK_THIS, 64562349, avlan, avid);
        // llMessageLinked(LINK_THIS, 64562349, avlan, avid);
}
    }
}
}
 
string addNewAgent(key newavid)
string addNewAgent(key newavid)
{
{
string speakerLan;
    string speakerLan;
if (llGetAgentSize(newavid) == ZERO_VECTOR)
    if (llGetAgentSize(newavid) == ZERO_VECTOR)
{
    {
speakerLan = "en";
        speakerLan = "en";
addAgent(newavid, speakerLan, 4);
        addAgent(newavid, speakerLan, 4);
}
    }
else
    else
{
    {
speakerLan  = checkLanguage(llGetAgentLanguage(newavid));
        speakerLan  = checkLanguage(llGetAgentLanguage(newavid));
if (speakerLan == "")
        if (speakerLan == "")
{
        {
speakerLan = "en";
            speakerLan = "en";
addAgent(newavid, speakerLan, 0);
            addAgent(newavid, speakerLan, 0);
}
        }
else
        else
{
        {
addAgent(newavid, speakerLan, 0);
            addAgent(newavid, speakerLan, 0);
}
        }
}
    }
return speakerLan;
    return speakerLan;
}
}
 
key getAgentKey(integer agentID)
key getAgentKey(integer agentID)
{
{
if(~llListFindList(agentsInTranslation, (list)agentID))
    if(~llListFindList(agentsInTranslation, (list)agentID))
{
    {
integer gkliPos = llListFindList(agentsInTranslation, (list)agentID);
        integer gkliPos = llListFindList(agentsInTranslation, (list)agentID);
return llList2Key(agentsInTranslation, gkliPos - 3);
        return llList2Key(agentsInTranslation, gkliPos - 4);
}
    }
else
    else
{
    {
return "";
        return "";
}
    }
}
}
 
processHTTPResponse(integer ntype, string bodyStr, list httli)
processHTTPResponse(integer ntype, string bodyStr, list httli)
{
{
key    recepientID;
    key    recepientID;
key    speakerID;
    key    speakerID;
list    paramtmpli;
    list    paramtmpli;
list    recepientList;
    list    recepientList;
string  recepientLanguage;
    string  recepientLanguage;
string  languagePair;
    string  languagePair;
string  speakerName;
    string  speakerName;
string  speakerLanguage;
    string  speakerLanguage;
string  translatedText;
    string  translatedText;
string  lantmpStr;
    string  lantmpStr;
integer z;
    integer z;
//===================
    //===================
//Process Translation
    //Process Translation
//===================
    //===================
speakerID  = llList2Key(httli, 1);
    speakerID  = llList2Key(httli, 1);
speakerName = llKey2Name(speakerID);
    speakerName = llKey2Name(speakerID);
if (speakerName == "")
    if (speakerName == "")
{
    {
speakerName = llList2String(llGetObjectDetails(speakerID, [OBJECT_NAME]), 0);
        speakerName = llList2String(llGetObjectDetails(speakerID, [OBJECT_NAME]), 0);
}
    }
recepientList = llParseString2List(llList2String(httli, 2), ["@"], []);
    recepientList = llParseString2List(llList2String(httli, 2), ["@"], []);
paramtmpli = llParseStringKeepNulls(llList2String(httli, 3), ["|"],[]);
    paramtmpli = llParseStringKeepNulls(llList2String(httli, 3), ["|"],[]);
recepientLanguage = llList2String(paramtmpli, 1);
    recepientLanguage = llList2String(paramtmpli, 1);
languagePair = llDumpList2String(paramtmpli, ">>");
    languagePair = llDumpList2String(paramtmpli, ">>");
//Perform Text Cleanup
    //Perform Text Cleanup
translatedText = llGetSubString(bodyStr, llSubStringIndex(bodyStr, "{\"translatedText\":\"") + 18, llSubStringIndex(bodyStr, "\",\"detectedSourceLanguage\":\""));
    translatedText = llGetSubString(bodyStr, llSubStringIndex(bodyStr, "{\"translatedText\":\"") + 18, llSubStringIndex(bodyStr, "\",\"detectedSourceLanguage\":\""));
//Reverse order if Recepient Language is Hebrew or Arabic
    //Reverse order if Recepient Language is Hebrew or Arabic
if ((recepientLanguage == "iw") || (recepientLanguage == "ar"))
    if ((recepientLanguage == "iw") || (recepientLanguage == "ar"))
{
    {
lantmpStr = "";
        lantmpStr = "";
for(z = llStringLength(translatedText);z >= 0; z--)
        for(z = llStringLength(translatedText);z >= 0; z--)
{
        {
lantmpStr = (lantmpStr="") + lantmpStr + llGetSubString(translatedText, z, z);
            lantmpStr = (lantmpStr="") + lantmpStr + llGetSubString(translatedText, z, z);
}
        }
translatedText = lantmpStr;
        translatedText = lantmpStr;
}
    }
lantmpStr = speakerName + "(" + languagePair + "): " + translatedText;
    lantmpStr = speakerName + "(" + languagePair + "): " + translatedText;
for (z = 0; z < llGetListLength(recepientList); z += 1)
    for (z = 0; z < llGetListLength(recepientList); z += 1)
{
    {
recepientID = getAgentKey(llList2Integer(recepientList, z));
        recepientID = getAgentKey(llList2Integer(recepientList, z));
if (recepientID != "")
        if (recepientID != "")
{
        {
recepientLanguage = llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [recepientID]) + 1);
            recepientLanguage = llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [recepientID]) + 1);
if (recepientLanguage == speakerLanguage)
            if (recepientLanguage == speakerLanguage)
{ }
            { }
else
            else
{
            {
sendIM(recepientID, lantmpStr);
                sendIM(recepientID, lantmpStr);
}
            }
}
        }
}
    }
return;
    return;
}
}
 
default
default
{
{
state_entry()
    state_entry()
{
    {
llSetTimerEvent(5);
        llSetTimerEvent(5);
}
    }
 
link_message(integer sender_num, integer num, string lstr, key lid)
    link_message(integer sender_num, integer num, string lstr, key lid)
{
    {
list ltmpli;
        list ltmpli;
if (num == 8434532)
        if (num == 8434532)
{
        {
enabled = (integer)lstr;
            enabled = (integer)lstr;
}
        }
else if (num == 3342976)
        else if (num == 3342976)
{ //Send Preferences
        {   //Send Preferences
options = lstr;
            options = lstr;
if (isInitialized == FALSE) return;
            if (isInitialized == FALSE) return;
ltmpli = llCSV2List(options);
            ltmpli = llCSV2List(options);
showTranslation = llList2Integer(ltmpli, 0);
            showTranslation = llList2Integer(ltmpli, 0);
tranObjects = llList2Integer(ltmpli, 1);
            tranObjects = llList2Integer(ltmpli, 1);
autoLanguage = llList2Integer(ltmpli, 2);
            autoLanguage = llList2Integer(ltmpli, 2);
}
        }
}
    }
 
sensor(integer num_detected)
    sensor(integer num_detected)
{
    {
integer s;
        integer s;
key sid;
        key sid;
for (s = 0; s < num_detected; s += 1)
        for (s = 0; s < num_detected; s += 1)
{
        {
sid = llDetectedKey(s);
            sid = llDetectedKey(s);
if (~llListFindList(agentsInTranslation, (list)sid))
            if (~llListFindList(agentsInTranslation, (list)sid))
{ }
            { }
else
            else
{
            {
addNewAgent(sid);
                addNewAgent(sid);
}
            }
}
        }
}
    }
 
no_sensor()
    no_sensor()
{ }
    { }
 
listen(integer channel, string name, key id, string message)
    listen(integer channel, string name, key id, string message)
{
    {
integer w;
        integer w;
string  spkrLan;
        string  spkrLan;
string  recepLan;
        string  recepLan;
integer recepID;
        integer recepID;
integer lstliPos;
        integer lstliPos;
string  lanpair;
        string  lanpair;
list    translationCache;
        list    translationCache;
//Translator Engine Code
        //Translator Engine Code
if ((!enabled) && (isMaster == 1))
        integer msgid = llRound(llFrand(2000000)) + 1;
{
        CheckSpell(msgid , llEscapeURL(message));
return;
        if ((!enabled) && (isMaster == 1))
}
        {
if (!tranObjects)
            return;
{
        }
if (llGetAgentSize(id) == ZERO_VECTOR)
        if (!tranObjects)
{
        {
return;
            if (llGetAgentSize(id) == ZERO_VECTOR)
}
            {
else
                return;
{
            }
detectLanguage(message, id);
            else
}
            {
}
                DetectLanguage(message, id);
else
            }
{
        }
detectLanguage(message, id);
        else
}
        {
if (~llListFindList(agentsInTranslation, (list)id))
            DetectLanguage(message, id);
{
        }
lstliPos = llListFindList(agentsInTranslation, (list)id);
        if (~llListFindList(agentsInTranslation, (list)id))
spkrLan = llList2String(agentsInTranslation, lstliPos + 1);
        {
}
            lstliPos = llListFindList(agentsInTranslation, (list)id);
else
            spkrLan = llList2String(agentsInTranslation, lstliPos + 1);
{
        }
spkrLan = addNewAgent(id);
        else
}
        {
//===============================
            spkrLan = addNewAgent(id);
//Formulate Translation Requests
        }
//===============================
 
if (id == llGetOwner())
 
{ // If speaker is owner
 
// I will do this dirty cheat by now
        //===============================
// There should exist another clean way to filter speakers & receivers, I need to think about this
        //Formulate Translation Requests
for (w = 0; w < llGetListLength(agentsInTranslation); w += 4)
        //===============================
{ //Loop through translation group and do appropriate translations as needed
        if (id == llGetOwner())
recepID = llList2Integer(agentsInTranslation, w + 3);
        {   // If speaker is owner
recepLan =  checkLanguage(llList2String(agentsInTranslation, w + 1));
            // I will do this dirty cheat by now
if (spkrLan == recepLan)
            // There should exist another clean way to filter speakers & receivers, I need to think about this
{ }
            for (w = 0; w < llGetListLength(agentsInTranslation); w += 5)
else
            {   //Loop through translation group and do appropriate translations as needed
{
                recepID = llList2Integer(agentsInTranslation, w + 4);
lanpair = spkrLan + "|" + recepLan;
                recepLan =  checkLanguage(llList2String(agentsInTranslation, w + 1));
if (~llListFindList(translationCache, (list)lanpair))
                if (spkrLan == recepLan)
{
                { }
lstliPos = llListFindList(translationCache, (list)lanpair);
                else
translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
                {
}
                    lanpair = spkrLan + "|" + recepLan;
else
                    if (~llListFindList(translationCache, (list)lanpair))
{
                    {
translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
                        lstliPos = llListFindList(translationCache, (list)lanpair);
}
                        translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
}
                    }
}
                    else
if (translationCache != [])
                    {
{ //Process Requests
                        translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
for (w = 0; w < llGetListLength(translationCache); w += 2)
                    }
{ //====================================
                }
//Translation
            }
//====================================
            if (translationCache != [])
//Forumulate and Send Translation Request
            {   //Process Requests
lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, w), ["|"],[]), 1);
                llSleep(1.0);
Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, w + 1), llList2String(translationCache, w)]);
                if (~llListFindList(corrections, (list)msgid))
}
                {
}
                    integer splchknum = llListFindList(corrections, (list)msgid);
}
                    message = llList2String(corrections, splchknum + 1 );
else
                    corrections = llDeleteSubList(corrections, splchknum,splchknum + 1);
{ // if speaker is not owner
                }
lstliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
                else
recepID = llList2Integer(agentsInTranslation, lstliPos + 3);
                {
recepLan =  checkLanguage(llList2String(agentsInTranslation , lstliPos + 1 ));
                    corrections = [];
if (spkrLan == recepLan)
                }
{ }
                for (w = 0; w < llGetListLength(translationCache); w += 2)
else
                {    //====================================
{
                    //Translation
lanpair = spkrLan + "|" + recepLan;
                    //====================================
if (~llListFindList(translationCache, (list)lanpair))
                    //Forumulate and Send Translation Request
{
                    lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, w), ["|"],[]), 1);
lstliPos = llListFindList(translationCache, (list)lanpair);
                    Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, w + 1), llList2String(translationCache, w)]);
translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
                }
}
            }
else
        }
{
        else
translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
        {   // if speaker is not owner
}
            lstliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
if (translationCache != [])
            recepID = llList2Integer(agentsInTranslation, lstliPos + 4);
{ //====================================
            recepLan =  checkLanguage(llList2String(agentsInTranslation , lstliPos + 1 ));
//Translation
            if (spkrLan == recepLan)
//====================================
            { }
//Forumulate and Send Translation Request
            else
lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, lstliPos), ["|"],[]), 1);
            {
Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, lstliPos + 1), llList2String(translationCache, lstliPos)]);
                lanpair = spkrLan + "|" + recepLan;
}
                if (~llListFindList(translationCache, (list)lanpair))
}
                {
}
                    lstliPos = llListFindList(translationCache, (list)lanpair);
}
                    translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
                }
http_response(key request_id, integer status, list metadata, string body)
                else
{ //Process Response Code
                {
integer httliPos;
                    translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
if (~llListFindList(requestedTranslations, (list)request_id))
                }
{
                if (translationCache != [])
httliPos = llListFindList(requestedTranslations, [request_id]);
                {   //====================================
processHTTPResponse(0, body, llCSV2List(llList2String(requestedTranslations, httliPos + 1)));
                    //Translation
requestedTranslations = llDeleteSubList(requestedTranslations, httliPos, httliPos + 1);
                    //====================================
return;
                    //Forumulate and Send Translation Request
}
                    lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, lstliPos), ["|"],[]), 1);
if (~llListFindList(tempDetections, (list)request_id))
                    Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, lstliPos + 1), llList2String(translationCache, lstliPos)]);
{ // We Trust the Google system, the Google´s guys are good and I am sure they will keep improving :-)
                }
integer tmpliPos = llListFindList(tempDetections, (list)request_id);
            }
key speakerID = llList2Key(tempDetections, tmpliPos + 1);
        }
tempDetections = llDeleteSubList(tempDetections, tmpliPos, tmpliPos + 3);
    }
string htttmpStr = llToLower(llGetSubString(body, llSubStringIndex(body, "{\"language\":\"") + 13, llSubStringIndex(body, "\",\"isReliable\":") - 1));
 
if (contains(htttmpStr, "err") == 0 && contains(htttmpStr, "unn") == 0)
    http_response(key request_id, integer status, list metadata, string body)
{ // if detects any language
    {   //Process Response Code
htttmpStr = checkLanguage(htttmpStr);
        integer httliPos;
if (~llListFindList(agentsInTranslation, (list)speakerID))
        if (~llListFindList(spellchecks, (list)request_id))
{
        {
integer tmpavliPos = llListFindList(agentsInTranslation, (list)speakerID);
            if(contains(body, "<Result>") != 0)
string actlan = llList2String(agentsInTranslation, tmpavliPos + 1);
            {    // Yahoo Spell Checker correction
if (llList2Integer(agentsInTranslation, tmpavliPos + 2) >= 3)
                integer httsplliPos = llListFindList(spellchecks, (list)request_id);
{ // if anyone speaks on any different language 3 times in a row
                integer httsplID = llList2Integer(spellchecks, httsplliPos + 1);
addAgent(speakerID, htttmpStr, 0);
                corrections = (corrections=[]) + corrections + [ httsplID, llGetSubString(body, llSubStringIndex(body, "<Result>") + 8, llSubStringIndex(body, "</Result>") - 1)];               
}
                spellchecks = llDeleteSubList(spellchecks, httsplliPos, httsplliPos + 1 );
if (actlan == htttmpStr)
            }
{ // reset language checker for speaker
            else
agentsInTranslation = llListReplaceList(agentsInTranslation,[0], tmpavliPos + 2, tmpavliPos + 2);
            {
}
                integer httsplliPos = llListFindList(spellchecks, (list)request_id);
else
                spellchecks = llDeleteSubList(spellchecks, httsplliPos, httsplliPos + 1 );
{ // if language of speaker is not the same as detected language
            }
agentsInTranslation = llListReplaceList(agentsInTranslation,[llList2Integer(agentsInTranslation,tmpavliPos + 2) + 1] , tmpavliPos + 2, tmpavliPos + 2);
        }
} }
        if (~llListFindList(requestedTranslations, (list)request_id))
}
        {
}
            httliPos = llListFindList(requestedTranslations, (list)request_id);
}
            processHTTPResponse(0, body, llCSV2List(llList2String(requestedTranslations, httliPos + 1)));
            requestedTranslations = llDeleteSubList(requestedTranslations, httliPos, httliPos + 1);
            return;
        }
        if (~llListFindList(tempDetections, (list)request_id))
        {   // We Trust the Google system, the Google´s guys are good and I am sure they will keep improving :-)
            integer tmpliPos = llListFindList(tempDetections, (list)request_id);
            key speakerID = llList2Key(tempDetections, tmpliPos + 1);
            tempDetections = llDeleteSubList(tempDetections, tmpliPos, tmpliPos + 3);
            string htttmpStr = llToLower(llGetSubString(body, llSubStringIndex(body, "{\"language\":\"") + 13, llSubStringIndex(body, "\",\"isReliable\":") - 1));
            if (contains(htttmpStr, "err") == 0 && contains(htttmpStr, "unn") == 0)
            {    // if detects any language
                htttmpStr = checkLanguage(htttmpStr);
                if (~llListFindList(agentsInTranslation, (list)speakerID))
                {
                    integer tmpavliPos = llListFindList(agentsInTranslation, (list)speakerID);
                    string actlan = llList2String(agentsInTranslation, tmpavliPos + 1);
                    if (llList2Integer(agentsInTranslation, tmpavliPos + 3) >= 2)
                    {    // if anyone speaks on any different language 3 times in a row
                        addAgent(speakerID, htttmpStr, 0);
                    }
                    if (actlan == htttmpStr)
                    {    // reset language checker for speaker
                        agentsInTranslation = llListReplaceList(agentsInTranslation, [ actlan, 0 ], tmpavliPos + 2, tmpavliPos + 3);
                    }
                    else
                    {
                        if ( htttmpStr == llList2String(agentsInTranslation,tmpavliPos + 2))
                        { // if language of speaker is not the same as detected language
                            agentsInTranslation = llListReplaceList(agentsInTranslation,[llList2Integer(agentsInTranslation,tmpavliPos + 3) + 1] , tmpavliPos + 3, tmpavliPos + 3);
                        }
                        else
                        {
                            agentsInTranslation = llListReplaceList(agentsInTranslation,[htttmpStr, 0] , tmpavliPos + 2, tmpavliPos + 3);
                        }
                    }
                }
            }
        }
    }


    timer()
timer()
    {
{
        integer r;
integer r;
        vector  tmrVct;
vector  tmrVct;
        list  newList;
list  newList;
        float timeElapsed;
float timeElapsed;
        llSetTimerEvent(0.0); // we better reset timer by way of precaution
llSetTimerEvent(0.0); // we better reset timer by way of precaution
        if (isInitialized == FALSE)
if (isInitialized == FALSE)
        {
{
            enabled = TRUE;
enabled = TRUE;
            listenID = llListen(0, "", "", "");
listenID = llListen(0, "", "", "");
            llMessageLinked(LINK_THIS, 6877259, (string)enabled, NULL_KEY);
llMessageLinked(LINK_THIS, 6877259, (string)enabled, NULL_KEY);
            isInitialized = TRUE;
isInitialized = TRUE;
            string mylanguage = llGetAgentLanguage(llGetOwner());
string mylanguage = llGetAgentLanguage(llGetOwner());
            if (llStringLength(mylanguage) < 1)
if (llStringLength(mylanguage) < 1)
            {
{
                mylanguage = "en";
mylanguage = "en";
            }
}
            if(~llListFindList(agentsInTranslation, (list)llGetOwner()))
if(~llListFindList(agentsInTranslation, (list)llGetOwner()))
            {
{
                integer ownerliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
integer ownerliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
                agentsInTranslation = llListReplaceList(agentsInTranslation, [mylanguage] , ownerliPos + 1, ownerliPos + 1);
agentsInTranslation = llListReplaceList(agentsInTranslation, [mylanguage] , ownerliPos + 1, ownerliPos + 1);
            }
}
            else
else
            {
{
                agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [llGetOwner() , mylanguage, mylanguage , 0 , llRound(llFrand(2000000)) + 1];
agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [llGetOwner() , mylanguage , 0 , llRound(llFrand(2000000)) + 1];
            }
}
        }
}
        for (r = 0; r < llGetListLength(tempDetections); r += 2)
for (r = 0; r < llGetListLength(tempDetections); r += 2)
        {
{
            timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(tempDetections, r + 1)), 0);
timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(tempDetections, r + 1)), 0);
            if (timeElapsed < 20.0)
if (timeElapsed < 30.0)
            {
{
                newList = (newList=[]) + newList + llList2List(tempDetections, r, r + 1);
newList = (newList=[]) + newList + llList2List(tempDetections, r, r + 1);
            }
}
        }
}
        tempDetections = newList;
tempDetections = newList;
        newList = [];
newList = [];
        for (r = 0; r < llGetListLength(requestedTranslations); r += 2)
for (r = 0; r < llGetListLength(requestedTranslations); r += 2)
        {
{
            timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedTranslations, r + 1)), 0);
timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedTranslations, r + 1)), 0);
            if (timeElapsed < 20.0)
if (timeElapsed < 30.0)
            {
{
                newList = (newList=[]) + newList + llList2List(requestedTranslations, r, r + 1);
newList = (newList=[]) + newList + llList2List(requestedTranslations, r, r + 1);
            }
}
        }
}
        requestedTranslations = newList;
requestedTranslations = newList;
        newList = [];
newList = [];
        if (isMaster > 0)
if (isMaster > 0)
        {
{
            for (r = 0; r < llGetListLength(agentsInTranslation); r += 5)
for (r = 0; r < llGetListLength(agentsInTranslation) r += 4)
            {
{
                tmrVct = llList2Vector(llGetObjectDetails(llList2Key(agentsInTranslation, r), [OBJECT_POS]), 0);
tmrVct = llList2Vector(llGetObjectDetails(llList2Key(agentsInTranslation, r), [OBJECT_POS]), 0);
                if (llVecDist(llGetPos(), tmrVct) <= 20.0)
if (llVecDist(llGetPos(), tmrVct) <= 20.0)
                {
{
                    newList = (newList=[]) + newList + llList2List(agentsInTranslation, r, r + 4);
newList = (newList=[]) + newList + llList2List(agentsInTranslation, r, r + 3);
                }
}
            }
}
            agentsInTranslation = newList;
agentsInTranslation = newList;
            newList = [];
newList = [];
        }
}
        if ((autoLanguage) && isMaster > 0)
if ((autoLanguage) && isMaster > 0)
        {
{
            llSensor("", NULL_KEY, AGENT, 20.0, PI);
llSensor("", NULL_KEY, AGENT, 20.0, PI);
        }
}
        llSetTimerEvent(4.0); // restart timer
llSetTimerEvent(4.0); // restart timer
    }
}
}
}


</lsl>
</lsl>

Revision as of 17:48, 22 December 2009

Bienvenid@

Hola, soy Perry Mizin y este será mi humilde intento de contribución al proyecto "Traductor Universal de Google" creado por Hank Ramos.

El siguiente código fué originálmente creado por Hank Ramos, empezaré modificando algunas funciones a mí manera... No ós riais

Welcome

Hello, I am Perry Mizin and this will be my humble try to contribute with the project "Universal Google Translator" created by Hank Ramos.

The next code was originally created by Hank Ramos, I will start modifiying some functions on my way... Don´t laugh


OK

Bueno, despues de respiñar todo lo que pude, creo que el uso de memoria y la velocidad están prácticamente igual qué en la versión original pero bueno... en la variedad está el gusto no? Ya he probado un poco el código, y parece que funciona aunque estoy teniendo algunos problemas... Por ejemplo creo que el sistema de traduccion no funciona corréctamente, y no me refiero al sistema de traduccion de Google (en mi opinion, si no es el mejor, es uno de los mejores del mundo), sino a que aún queda mucho trabajo por hacer en el script...

El siguiente paso sera intentar dividir el script en dos, o si es posible en tres para repartir el uso de memoria. Tambien me gustaria probar un truco que uso a menudo para traducir páginas en un idioma que no entiendo, lo que hago es que en vez de traducir diréctamente al español, primero se traduce a inglés, y luego desde inglés al español. Parece una tontería y un gasto innecesario, pero si lo hago es porque así suelo entender mejor las traducciones. Quiero por un lado el sistema de comunicacion y evaluacion entre traductores, y por otro el sistema de traduccion entre avatares, ¿es muy dificil? no sé ya lo veremos...

Well, after saving as much as I could, I think the memory usage and the speed are technically the same as in the original script, but well, in the variety is the taste, isnt it?. I have tested a bit the code above already, and it seems to work altought i´m having some problems... For instance i think the translation system is not working properly, and i dont mean the Google´s translation system (in my opinion, if is not the best, one of the bests), but that there is still much work to do in the script...

The next step will be to try to divide the script in 2, or 3 if is possible, so we can spread the memory usage. Also I would like to test a trick i use often for to translate languages that i dont understand, what I do first is to translate that language into English, and then from English to Spanish, it seems a nonsense and unnecesary waste, but if i do it is becouse so i usually understand the translations better. I want by one part the translators communications and evaluation system, and by other the translation system between avatars, is it very difficult? I don´t know , we will see...


Es dificil... me está costando pero ya veremos... Its difficult... i am struggling but we will see...

chu chu chu


De Güatemala a Güatepeor, Sin comentarios...

From Güatebad to Güateworse, No comments...

Buscando en Internet he encontrado este API de Yahoo comprobador de ortografía, aunque creo que por ahora sólo soporta el lenguage inglés pero sería interesante añadirlo al proyecto

Searching on the web I crossed in my way with this spell checker Yahoo´s API , I think that it only supports English language by now althought it would be interesting to add it to the project


Estoy probando el comprobador de deletreo de Yahoo aunque la verdad es que no estoy teniendo buenos resultados, parece que Google es mucho más rapido y necesito corregir antes de traducir. También estoy intentando solucionar el error que aparece con el símbolo (apostrofe) ´ en las frases con genitivo sajon traducidas al inglés y tampoco doy con la tecla... Ya que esto me está dando muchos dolores de cabeza quizás deje el proyecto en standby hasta después de navidades.

I am testing the Yahoo´s spell checker althought to be honest I´m not having good success, it seems Google is much faster and I need to correct before translate. Also I am triying to fix the error showed in the phrases translated to English with the saxons genitive apostrophe ´ and still triying and triying. As this is driving me nuts, maybe I will leave the project in standby until new year.



ESTO ES EL TRADUCTOR "un lío" por ahora... Necesito rehacer algunas cosas

THIS IS THE TRANSLATOR "mess" by now... I need to redo some things


<lsl> //Personal Translator (Mod made in Perry Mizin) //Universal Translator //Version 1.9.0 //November 12, 2009 //LSL Script copyright 2006-2009 by Hank Ramos //Translation Web Services powered by Google //Spell Checker Web Services powered by Yahoo //Variables list requestedTranslations; list tempDetections; list agentsInTranslation; list spellchecks; list corrections; integer M = 1; integer listenID; integer isMaster = 1; integer autoLanguage = TRUE; integer enabled = FALSE; integer showTranslation = FALSE; integer tranObjects = TRUE; integer isInitialized = FALSE; string options; string tempcorrection; key tempValue; //Functions integer contains(string haystack, string needle) // http://wiki.secondlife.com/wiki/llSubStringIndex {

   return ~llSubStringIndex(haystack, needle);

}

sendIM(key imid, string imstr) {

   // llInstantMessage(key id , string message) causes the script to sleep for 2 seconds
   if (llGetAgentSize(imid) == ZERO_VECTOR)
   { }
   else
   {
       if (imid != llGetOwner())
       {
           llOwnerSay(imstr + " @" + llKey2Name(imid));  //llOwnerSay(string message) has no delay
       }
   }
   if (M == 8)
   {
       llMessageLinked(LINK_THIS, 2334420, imstr, imid);
       M = 1;
   }
   else if (M == 7)
   {
       llMessageLinked(LINK_THIS, 2334430, imstr, imid);
       M = 8;
   }
   else if (M == 6)
   {
       llMessageLinked(LINK_THIS, 2334440, imstr, imid);
       M = 7;
   }
   else if (M == 5)
   {
       llMessageLinked(LINK_THIS, 2334450, imstr, imid);
       M = 6;
   }
   else if (M == 4)
   {
       llMessageLinked(LINK_THIS, 2334460, imstr, imid);
       M = 5;
   }
   else if (M == 3)
   {
       llMessageLinked(LINK_THIS, 2334470, imstr, imid);
       M = 4;
   }
   else if (M == 2)
   {
       llMessageLinked(LINK_THIS, 2334480, imstr, imid);
       M = 3;
   }
   else if (M == 1)
   {
       llMessageLinked(LINK_THIS, 2334490, imstr, imid);
       M = 2;
   }

}

DetectLanguage(string dtcmsg, key dtcid) {

   tempValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=" + llEscapeURL(dtcmsg), [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], " ");
   if (tempValue != NULL_KEY)
   {
       tempDetections = (tempDetections=[]) + tempDetections + [tempValue, dtcid];
   }

}

CheckSpell(integer splnum, string splmsg) {

   key spellValue;
   spellValue = llHTTPRequest("http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?appid=DNPjiabV34EOgXQ3kAu6.d7kf6v.JUGCn1bFUcSTFMSGCyCy_ALzbepYstlI7DrOGP0-&query=" + splmsg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], "");
   if (spellValue != NULL_KEY)
   {    //Translation
       spellchecks = (spellchecks=[]) + spellchecks + [spellValue, splnum];
   }

}

Translate(integer chkn, string chkmsg, list chkli) {

   key returnValue;
   returnValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" + chkmsg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], "");
   if (returnValue != NULL_KEY)
   {    //Translation
       requestedTranslations = (requestedTranslations=[]) + requestedTranslations + [returnValue, llList2CSV(chkli)];
   }
   else
   {
       llSleep(25.0); //Something has gone horribly wrong, sleep 25 seconds to clear throttle
   }

}

string checkLanguage(string chklantmpStr) {

   if (chklantmpStr == "")
   {
       chklantmpStr = "en";
   }
   else if (chklantmpStr == "und")
   {
       chklantmpStr = "el";
   }
   if (llGetSubString(chklantmpStr, 0, 1) == "zh")
   {
       chklantmpStr = "zh-CN";
   }
   else
   {
       chklantmpStr = llGetSubString(chklantmpStr, 0, 1);
   }
   return chklantmpStr;

}

addAgent(key avid, string avlan, integer chklan) {

   integer avliPos;
   integer idNum;
   if (~llListFindList(agentsInTranslation, (list)avid))
   {
       avliPos = llListFindList(agentsInTranslation, (list)avid);
       agentsInTranslation = llListReplaceList(agentsInTranslation, [avlan, avlan, chklan], avliPos + 1, avliPos + 3);
   }
   else
   {
       @at;
       idNum = llRound(llFrand(2000000)) + 1;
       if(~llListFindList(agentsInTranslation, (list)idNum))
       {
           jump at;
       }
       agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [avid, avlan, avlan, chklan, idNum];
       // llMessageLinked(LINK_THIS, 64562349, avlan, avid);
   }

}

string addNewAgent(key newavid) {

   string speakerLan;
   if (llGetAgentSize(newavid) == ZERO_VECTOR)
   {
       speakerLan = "en";
       addAgent(newavid, speakerLan, 4);
   }
   else
   {
       speakerLan  = checkLanguage(llGetAgentLanguage(newavid));
       if (speakerLan == "")
       {
           speakerLan = "en";
           addAgent(newavid, speakerLan, 0);
       }
       else
       {
           addAgent(newavid, speakerLan, 0);
       }
   }
   return speakerLan;

}

key getAgentKey(integer agentID) {

   if(~llListFindList(agentsInTranslation, (list)agentID))
   {
       integer gkliPos = llListFindList(agentsInTranslation, (list)agentID);
       return llList2Key(agentsInTranslation, gkliPos - 4);
   }
   else
   {
       return "";
   }

}

processHTTPResponse(integer ntype, string bodyStr, list httli) {

   key     recepientID;
   key     speakerID;
   list    paramtmpli;
   list    recepientList;
   string  recepientLanguage;
   string  languagePair;
   string  speakerName;
   string  speakerLanguage;
   string  translatedText;
   string  lantmpStr;
   integer z;
   //===================
   //Process Translation
   //===================
   speakerID  = llList2Key(httli, 1);
   speakerName = llKey2Name(speakerID);
   if (speakerName == "")
   {
       speakerName = llList2String(llGetObjectDetails(speakerID, [OBJECT_NAME]), 0);
   }
   recepientList = llParseString2List(llList2String(httli, 2), ["@"], []);
   paramtmpli = llParseStringKeepNulls(llList2String(httli, 3), ["|"],[]);
   recepientLanguage = llList2String(paramtmpli, 1);
   languagePair = llDumpList2String(paramtmpli, ">>");
   //Perform Text Cleanup
   translatedText = llGetSubString(bodyStr, llSubStringIndex(bodyStr, "{\"translatedText\":\"") + 18, llSubStringIndex(bodyStr, "\",\"detectedSourceLanguage\":\""));
   //Reverse order if Recepient Language is Hebrew or Arabic
   if ((recepientLanguage == "iw") || (recepientLanguage == "ar"))
   {
       lantmpStr = "";
       for(z = llStringLength(translatedText);z >= 0; z--)
       {
           lantmpStr = (lantmpStr="") + lantmpStr + llGetSubString(translatedText, z, z);
       }
       translatedText = lantmpStr;
   }
   lantmpStr = speakerName + "(" + languagePair + "): " + translatedText;
   for (z = 0; z < llGetListLength(recepientList); z += 1)
   {
       recepientID = getAgentKey(llList2Integer(recepientList, z));
       if (recepientID != "")
       {
           recepientLanguage = llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [recepientID]) + 1);
           if (recepientLanguage == speakerLanguage)
           { }
           else
           {
               sendIM(recepientID, lantmpStr);
           }
       }
   }
   return;

}

default {

   state_entry()
   {
       llSetTimerEvent(5);
   }
   link_message(integer sender_num, integer num, string lstr, key lid)
   {
       list ltmpli;
       if (num == 8434532)
       {
           enabled = (integer)lstr;
       }
       else if (num == 3342976)
       {    //Send Preferences
           options = lstr;
           if (isInitialized == FALSE) return;
           ltmpli = llCSV2List(options);
           showTranslation = llList2Integer(ltmpli, 0);
           tranObjects = llList2Integer(ltmpli, 1);
           autoLanguage = llList2Integer(ltmpli, 2);
       }
   }
   sensor(integer num_detected)
   {
       integer s;
       key sid;
       for (s = 0; s < num_detected; s += 1)
       {
           sid = llDetectedKey(s);
           if (~llListFindList(agentsInTranslation, (list)sid))
           { }
           else
           {
               addNewAgent(sid);
           }
       }
   }
   no_sensor()
   { }
   listen(integer channel, string name, key id, string message)
   {
       integer w;
       string  spkrLan;
       string  recepLan;
       integer recepID;
       integer lstliPos;
       string  lanpair;
       list    translationCache;
       //Translator Engine Code
       integer msgid = llRound(llFrand(2000000)) + 1;
       CheckSpell(msgid , llEscapeURL(message));
       if ((!enabled) && (isMaster == 1))
       {
           return;
       }
       if (!tranObjects)
       {
           if (llGetAgentSize(id) == ZERO_VECTOR)
           {
               return;
           }
           else
           {
               DetectLanguage(message, id);
           }
       }
       else
       {
           DetectLanguage(message, id);
       }
       if (~llListFindList(agentsInTranslation, (list)id))
       {
           lstliPos = llListFindList(agentsInTranslation, (list)id);
           spkrLan = llList2String(agentsInTranslation, lstliPos + 1);
       }
       else
       {
           spkrLan = addNewAgent(id);
       }


       //===============================
       //Formulate Translation Requests
       //===============================
       if (id == llGetOwner())
       {    // If speaker is owner
           // I will do this dirty cheat by now
           // There should exist another clean way to filter speakers & receivers, I need to think about this
           for (w = 0; w < llGetListLength(agentsInTranslation); w += 5)
           {    //Loop through translation group and do appropriate translations as needed
               recepID = llList2Integer(agentsInTranslation, w + 4);
               recepLan =  checkLanguage(llList2String(agentsInTranslation, w + 1));
               if (spkrLan == recepLan)
               { }
               else
               {
                   lanpair = spkrLan + "|" + recepLan;
                   if (~llListFindList(translationCache, (list)lanpair))
                   {
                       lstliPos = llListFindList(translationCache, (list)lanpair);
                       translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
                   }
                   else
                   {
                       translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
                   }
               }
           }
           if (translationCache != [])
           {    //Process Requests
               llSleep(1.0);
               if (~llListFindList(corrections, (list)msgid))
               {
                   integer splchknum = llListFindList(corrections, (list)msgid);
                   message = llList2String(corrections, splchknum + 1 );
                   corrections = llDeleteSubList(corrections, splchknum,splchknum + 1);
               }
               else
               {
                   corrections = [];
               }
               for (w = 0; w < llGetListLength(translationCache); w += 2)
               {    //====================================
                   //Translation
                   //====================================
                   //Forumulate and Send Translation Request
                   lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, w), ["|"],[]), 1);
                   Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, w + 1), llList2String(translationCache, w)]);
               }
           }
       }
       else
       {    // if speaker is not owner
           lstliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
           recepID = llList2Integer(agentsInTranslation, lstliPos + 4);
           recepLan =  checkLanguage(llList2String(agentsInTranslation , lstliPos + 1 ));
           if (spkrLan == recepLan)
           { }
           else
           {
               lanpair = spkrLan + "|" + recepLan;
               if (~llListFindList(translationCache, (list)lanpair))
               {
                   lstliPos = llListFindList(translationCache, (list)lanpair);
                   translationCache = llListReplaceList(translationCache, [llList2String(translationCache, lstliPos + 1) + "@" + (string)recepID], lstliPos + 1, lstliPos + 1);
               }
               else
               {
                   translationCache = (translationCache=[]) + translationCache + [lanpair, recepID];
               }
               if (translationCache != [])
               {    //====================================
                   //Translation
                   //====================================
                   //Forumulate and Send Translation Request
                   lanpair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, lstliPos), ["|"],[]), 1);
                   Translate(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(lanpair), [llGetTime(), id , llList2String(translationCache, lstliPos + 1), llList2String(translationCache, lstliPos)]);
               }
           }
       }
   }
   http_response(key request_id, integer status, list metadata, string body)
   {    //Process Response Code
       integer httliPos;
       if (~llListFindList(spellchecks, (list)request_id))
       {
           if(contains(body, "<Result>") != 0)
           {    // Yahoo Spell Checker correction
               integer httsplliPos = llListFindList(spellchecks, (list)request_id);
               integer httsplID = llList2Integer(spellchecks, httsplliPos + 1);
               corrections = (corrections=[]) + corrections + [ httsplID, llGetSubString(body, llSubStringIndex(body, "<Result>") + 8, llSubStringIndex(body, "</Result>") - 1)];                
               spellchecks = llDeleteSubList(spellchecks, httsplliPos, httsplliPos + 1 );
           }
           else
           {
               integer httsplliPos = llListFindList(spellchecks, (list)request_id);
               spellchecks = llDeleteSubList(spellchecks, httsplliPos, httsplliPos + 1 );
           }
       }
       if (~llListFindList(requestedTranslations, (list)request_id))
       {
           httliPos = llListFindList(requestedTranslations, (list)request_id);
           processHTTPResponse(0, body, llCSV2List(llList2String(requestedTranslations, httliPos + 1)));
           requestedTranslations = llDeleteSubList(requestedTranslations, httliPos, httliPos + 1);
           return;
       }
       if (~llListFindList(tempDetections, (list)request_id))
       {    // We Trust the Google system, the Google´s guys are good and I am sure they will keep improving :-)
           integer tmpliPos = llListFindList(tempDetections, (list)request_id);
           key speakerID = llList2Key(tempDetections, tmpliPos + 1);
           tempDetections = llDeleteSubList(tempDetections, tmpliPos, tmpliPos + 3);
           string htttmpStr = llToLower(llGetSubString(body, llSubStringIndex(body, "{\"language\":\"") + 13, llSubStringIndex(body, "\",\"isReliable\":") - 1));
           if (contains(htttmpStr, "err") == 0 && contains(htttmpStr, "unn") == 0)
           {    // if detects any language
               htttmpStr = checkLanguage(htttmpStr);
               if (~llListFindList(agentsInTranslation, (list)speakerID))
               {
                   integer tmpavliPos = llListFindList(agentsInTranslation, (list)speakerID);
                   string actlan = llList2String(agentsInTranslation, tmpavliPos + 1);
                   if (llList2Integer(agentsInTranslation, tmpavliPos + 3) >= 2)
                   {    // if anyone speaks on any different language 3 times in a row
                       addAgent(speakerID, htttmpStr, 0);
                   }
                   if (actlan == htttmpStr)
                   {    // reset language checker for speaker
                       agentsInTranslation = llListReplaceList(agentsInTranslation, [ actlan, 0 ], tmpavliPos + 2, tmpavliPos + 3);
                   }
                   else
                   {
                       if ( htttmpStr == llList2String(agentsInTranslation,tmpavliPos + 2))
                       { // if language of speaker is not the same as detected language
                           agentsInTranslation = llListReplaceList(agentsInTranslation,[llList2Integer(agentsInTranslation,tmpavliPos + 3) + 1] , tmpavliPos + 3, tmpavliPos + 3);
                       }
                       else
                       {
                           agentsInTranslation = llListReplaceList(agentsInTranslation,[htttmpStr, 0] , tmpavliPos + 2, tmpavliPos + 3);
                       }
                   }
               }
           }
       }
   }
   timer()
   {
       integer r;
       vector  tmrVct;
       list  newList;
       float timeElapsed;
       llSetTimerEvent(0.0); // we better reset timer by way of precaution
       if (isInitialized == FALSE)
       {
           enabled = TRUE;
           listenID = llListen(0, "", "", "");
           llMessageLinked(LINK_THIS, 6877259, (string)enabled, NULL_KEY);
           isInitialized = TRUE;
           string mylanguage = llGetAgentLanguage(llGetOwner());
           if (llStringLength(mylanguage) < 1)
           {
               mylanguage = "en";
           }
           if(~llListFindList(agentsInTranslation, (list)llGetOwner()))
           {
               integer ownerliPos = llListFindList(agentsInTranslation, (list)llGetOwner());
               agentsInTranslation = llListReplaceList(agentsInTranslation, [mylanguage] , ownerliPos + 1, ownerliPos + 1);
           }
           else
           {
               agentsInTranslation = (agentsInTranslation=[]) + agentsInTranslation + [llGetOwner() , mylanguage, mylanguage , 0 , llRound(llFrand(2000000)) + 1];
           }
       }
       for (r = 0; r < llGetListLength(tempDetections); r += 2)
       {
           timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(tempDetections, r + 1)), 0);
           if (timeElapsed < 20.0)
           {
               newList = (newList=[]) + newList + llList2List(tempDetections, r, r + 1);
           }
       }
       tempDetections = newList;
       newList = [];
       for (r = 0; r < llGetListLength(requestedTranslations); r += 2)
       {
           timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedTranslations, r + 1)), 0);
           if (timeElapsed < 20.0)
           {
               newList = (newList=[]) + newList + llList2List(requestedTranslations, r, r + 1);
           }
       }
       requestedTranslations = newList;
       newList = [];
       if (isMaster > 0)
       {
           for (r = 0; r < llGetListLength(agentsInTranslation); r += 5)
           {
               tmrVct = llList2Vector(llGetObjectDetails(llList2Key(agentsInTranslation, r), [OBJECT_POS]), 0);
               if (llVecDist(llGetPos(), tmrVct) <= 20.0)
               {
                   newList = (newList=[]) + newList + llList2List(agentsInTranslation, r, r + 4);
               }
           }
           agentsInTranslation = newList;
           newList = [];
       }
       if ((autoLanguage) && isMaster > 0)
       {
           llSensor("", NULL_KEY, AGENT, 20.0, PI);
       }
       llSetTimerEvent(4.0); // restart timer
   }

}

</lsl>