No _vti
This commit is contained in:
@@ -1,826 +0,0 @@
|
||||
// :CATEGORY:Translator
|
||||
// :NAME:Universal_Google_Translator
|
||||
// :AUTHOR:Hank Ramos
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:39:08
|
||||
// :ID:934
|
||||
// :NUM:1340
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// The device consists of 3 key scripts, with several ancillary scripts to function. The key scripts are listed here...
|
||||
// Universal Translator Engine
|
||||
//
|
||||
// This is the "heart" of the translator. It handles communications with other translators, handles listening to avatars for chat, and handles most of the HTTP traffic.
|
||||
//
|
||||
// How do multiple translators communicate? There are two chat channels at work...
|
||||
//
|
||||
// The heartbeat channel: this channel is fixed and common amongst all Universal Translators. This is where each translator regularly announces its presence to other translators in the area. If another one is found, a "master' translator is elected at random (with higher version releases of the translators getting higher values). The master translator is in charge of listening to all chat, and sending text to be translated and IMed to the recipient to the other "slave" translators.
|
||||
//
|
||||
// Unique translator channel: each translator will select it's own channel to listen for incoming translations. This serves as a unique conduit for the master translator to communicate with each individual slave. This allows the heartbeat channel to be free for command messages to be sent, since the translated text being passed around can quickly saturate it.
|
||||
//
|
||||
// This multi-translator communication might be useful in other scripting projects.
|
||||
// :CODE:
|
||||
//Universal Translator
|
||||
|
||||
//Version 1.9.0
|
||||
|
||||
//November 12, 2009
|
||||
|
||||
//LSL Script copyright 2006-2009 by Hank Ramos
|
||||
|
||||
//Web Server Services powered by Google
|
||||
|
||||
|
||||
|
||||
//Variables
|
||||
|
||||
list agentsInTranslation;
|
||||
|
||||
list agentsInTranslationOptions;
|
||||
|
||||
list requestList;
|
||||
|
||||
integer listenID;
|
||||
|
||||
|
||||
|
||||
integer isMaster = 1;
|
||||
|
||||
integer autoLanguage = TRUE;
|
||||
|
||||
integer enabled = FALSE;
|
||||
|
||||
integer showTranslation = FALSE;
|
||||
|
||||
integer tranObjects = TRUE;
|
||||
|
||||
|
||||
|
||||
integer lastHeartBeat;
|
||||
|
||||
list languageCodes = [
|
||||
|
||||
"zh-CN", "zh-TW", "hr",
|
||||
|
||||
"bg", "be", "ca",
|
||||
|
||||
"af", "sq", "ar",
|
||||
|
||||
|
||||
|
||||
"tl", "fr", "gl",
|
||||
|
||||
"fi", "en", "et",
|
||||
|
||||
"cs", "da", "nl",
|
||||
|
||||
|
||||
|
||||
"id", "ga", "it",
|
||||
|
||||
"hi", "hu", "is",
|
||||
|
||||
"de", "el", "iw",
|
||||
|
||||
|
||||
|
||||
"mt", "no", "fa",
|
||||
|
||||
"lt", "mk", "ms",
|
||||
|
||||
"ja", "ko", "lv",
|
||||
|
||||
|
||||
|
||||
"sl", "es", "sw",
|
||||
|
||||
"ru", "sr", "sk",
|
||||
|
||||
"pl", "pt-PT", "ro",
|
||||
|
||||
|
||||
|
||||
"yi", "", "",
|
||||
|
||||
"uk", "vi", "cy",
|
||||
|
||||
"sv","th", "tr"];
|
||||
|
||||
|
||||
|
||||
list translators;
|
||||
|
||||
list sayCache;
|
||||
|
||||
list sayCachePrivate;
|
||||
|
||||
integer priorityNumber;
|
||||
|
||||
integer priorityNumListenID;
|
||||
|
||||
integer isInitialized = FALSE;
|
||||
|
||||
string options;
|
||||
|
||||
|
||||
|
||||
//Options
|
||||
|
||||
//integer debug = TRUE;
|
||||
|
||||
integer broadcastChannel = -9999999; //note this is not the channel used by the HR Universal Translator
|
||||
|
||||
string password = "password"; //note this is not the password used to encrypt comms of the HR Universal Translator
|
||||
|
||||
integer version = 190;
|
||||
|
||||
sendIM(key id, string str)
|
||||
|
||||
{
|
||||
|
||||
if (llGetParcelFlags(llGetPos()) & PARCEL_FLAG_ALLOW_SCRIPTS)
|
||||
|
||||
{
|
||||
|
||||
llMessageLinked(LINK_ALL_CHILDREN, 85234119, str, id);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
llMessageLinked(LINK_THIS, 85304563, str, id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
sendTextBatch(integer channel, string sendText)
|
||||
|
||||
{
|
||||
|
||||
sendText = llXorBase64StringsCorrect(llStringToBase64(sendText), llStringToBase64(password));;
|
||||
|
||||
while (llStringLength(sendText) > 508) //If string is 509 characters or longer
|
||||
|
||||
{
|
||||
|
||||
llSay(channel, llGetSubString(sendText, 0, 507)); //send 508 character chunk
|
||||
|
||||
sendText = llGetSubString(sendText, 508, -1); //delete 508 character chunk
|
||||
|
||||
}
|
||||
|
||||
llSay(channel, sendText); //send out any remainder chunk or original chunk
|
||||
|
||||
if (llStringLength(sendText) == 508)
|
||||
|
||||
llSay(channel, (string)(channel*4958654));
|
||||
|
||||
llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<0.25, 0, 0.25>, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
string receiveTextBatch(key id, string message)
|
||||
|
||||
{
|
||||
|
||||
integer listPos;
|
||||
|
||||
string tempString = "";
|
||||
|
||||
|
||||
|
||||
listPos = llListFindList(sayCache, [id]);
|
||||
|
||||
if (listPos >= 0)
|
||||
|
||||
{
|
||||
|
||||
while (listPos >= 0)
|
||||
|
||||
{
|
||||
|
||||
tempString = tempString + llList2String(sayCache, listPos + 1);
|
||||
|
||||
sayCache = llDeleteSubList(sayCache, listPos, listPos + 1);
|
||||
|
||||
listPos = llListFindList(sayCache, [id]);
|
||||
|
||||
}
|
||||
|
||||
message = tempString + message;
|
||||
|
||||
}
|
||||
|
||||
message = llBase64ToString(llXorBase64StringsCorrect(message, llStringToBase64(password)));
|
||||
|
||||
return message;
|
||||
|
||||
}
|
||||
|
||||
string receiveTextBatchPrivate(key id, string message)
|
||||
|
||||
{
|
||||
|
||||
integer listPos;
|
||||
|
||||
string tempString = "";
|
||||
|
||||
|
||||
|
||||
listPos = llListFindList(sayCachePrivate, [id]);
|
||||
|
||||
if (listPos >= 0)
|
||||
|
||||
{
|
||||
|
||||
while (listPos >= 0)
|
||||
|
||||
{
|
||||
|
||||
tempString = tempString + llList2String(sayCachePrivate, listPos + 1);
|
||||
|
||||
sayCachePrivate = llDeleteSubList(sayCachePrivate, listPos, listPos + 1);
|
||||
|
||||
listPos = llListFindList(sayCachePrivate, [id]);
|
||||
|
||||
}
|
||||
|
||||
message = tempString + message;
|
||||
|
||||
}
|
||||
|
||||
message = llBase64ToString(llXorBase64StringsCorrect(message, llStringToBase64(password)));
|
||||
|
||||
return message;
|
||||
|
||||
}
|
||||
|
||||
updateTranslatorList()
|
||||
|
||||
{
|
||||
|
||||
integer x;
|
||||
|
||||
integer listLength;
|
||||
|
||||
list newList;
|
||||
|
||||
string tempString;
|
||||
|
||||
integer newMaster;
|
||||
|
||||
|
||||
|
||||
//Scan and remove translators not in the area
|
||||
|
||||
for (x = 0; x < llGetListLength(translators); x += 2)
|
||||
|
||||
{
|
||||
|
||||
tempString = llList2String(llGetObjectDetails(llList2Key(translators, x + 1), [OBJECT_POS]), 0);
|
||||
|
||||
if ((llVecDist(llGetPos(), (vector)tempString) <= 20.0) && (tempString != ""))
|
||||
|
||||
newList += llList2List(translators, x, x + 1);
|
||||
|
||||
}
|
||||
|
||||
translators = newList;
|
||||
|
||||
|
||||
|
||||
listLength = llGetListLength(translators);
|
||||
|
||||
llMessageLinked(LINK_THIS, 65635544, (string)listLength, "");
|
||||
|
||||
|
||||
|
||||
if (listLength == 0)
|
||||
|
||||
{
|
||||
|
||||
newMaster = 1;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
if (enabled)
|
||||
|
||||
{
|
||||
|
||||
newMaster = 2;
|
||||
|
||||
for (x = 0; x < llGetListLength(translators); x += 2)
|
||||
|
||||
{
|
||||
|
||||
//llOwnerSay("Checking Priority Number(" + (string)priorityNumber + "): " + (string)llList2Integer(translators, x));
|
||||
|
||||
if (llList2Integer(translators, x) > priorityNumber)
|
||||
|
||||
{
|
||||
|
||||
newMaster = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
newMaster = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((isMaster > 0) && (newMaster == 0))
|
||||
|
||||
{
|
||||
|
||||
//We are being demoted from master to slave
|
||||
|
||||
//Flush agentsInTranslation to master
|
||||
|
||||
if (llGetListLength(agentsInTranslation) > 0)
|
||||
|
||||
{
|
||||
|
||||
//Demotion Dump of agentsInTranslation to Master
|
||||
|
||||
sendTextBatch(broadcastChannel, llList2CSV([1003, llList2CSV(agentsInTranslation)]));
|
||||
|
||||
if (isInitialized == FALSE) return;
|
||||
|
||||
sendTextBatch(broadcastChannel, llList2CSV([1004, options])); //error
|
||||
|
||||
}
|
||||
|
||||
llListenRemove(listenID);
|
||||
|
||||
}
|
||||
|
||||
if ((isMaster == 0) && (newMaster > 0))
|
||||
|
||||
{
|
||||
|
||||
llListenRemove(listenID);
|
||||
|
||||
listenID = llListen(0, "", "", "");
|
||||
|
||||
}
|
||||
|
||||
isMaster = newMaster;
|
||||
|
||||
llMessageLinked(LINK_THIS, 34829304, (string)isMaster, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
sendHeartbeat()
|
||||
|
||||
{
|
||||
|
||||
updateTranslatorList();
|
||||
|
||||
sendTextBatch(broadcastChannel, llList2CSV([1001, priorityNumber]));
|
||||
|
||||
|
||||
|
||||
//Broadcast agentList to Slaves
|
||||
|
||||
if (isMaster == 2)
|
||||
|
||||
{
|
||||
|
||||
sendTextBatch(broadcastChannel, llList2CSV([1002, llList2CSV(agentsInTranslation)]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Functions
|
||||
|
||||
checkThrottle(integer num, string msg, list params)
|
||||
|
||||
{
|
||||
|
||||
integer x;
|
||||
|
||||
integer maxCount;
|
||||
|
||||
float oldTime;
|
||||
|
||||
float sleepTime;
|
||||
|
||||
list newList;
|
||||
|
||||
key returnValue;
|
||||
|
||||
integer channelToSpeak;
|
||||
|
||||
|
||||
|
||||
//loop though list and remove items older than 25 seconds
|
||||
|
||||
for (x = 0; x < llGetListLength(requestList); x += 1)
|
||||
|
||||
{
|
||||
|
||||
oldTime = llList2Float(requestList, x);
|
||||
|
||||
//Construct new list with only times less than 25 seconds
|
||||
|
||||
if ((llGetTime() - oldTime) <= 25.0)
|
||||
|
||||
newList += oldTime;
|
||||
|
||||
}
|
||||
|
||||
requestList = newList;
|
||||
|
||||
|
||||
|
||||
x = llGetListLength(requestList);
|
||||
|
||||
|
||||
|
||||
//Shunt all translations to linked translators if master
|
||||
|
||||
if (isMaster == 2)
|
||||
|
||||
{
|
||||
|
||||
if (num == 0)
|
||||
|
||||
{
|
||||
|
||||
//Send HTTP request to other translator
|
||||
|
||||
//Send out Request to Random Translator Channel
|
||||
|
||||
|
||||
|
||||
channelToSpeak = llList2Integer(llListRandomize(llList2ListStrided(translators, 0, -1, 2), 1), 0);
|
||||
|
||||
if (channelToSpeak > 0)
|
||||
|
||||
{
|
||||
|
||||
sendTextBatch(channelToSpeak, llList2CSV([num, llList2CSV(params)]) + "~" + msg);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (x == 19)
|
||||
|
||||
{
|
||||
|
||||
sleepTime = 25.0 - (llGetTime() - llList2Float(requestList, 0));
|
||||
|
||||
if (sleepTime > 0)
|
||||
|
||||
{
|
||||
|
||||
llSleep(sleepTime);
|
||||
|
||||
}
|
||||
|
||||
requestList = llDeleteSubList(requestList, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (num == 0)
|
||||
|
||||
{
|
||||
|
||||
msg = "translate?v=1.0&q=" + msg;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
msg = "detect?v=1.0&q=" + msg;
|
||||
|
||||
|
||||
|
||||
requestList += llGetTime();
|
||||
|
||||
returnValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/" + msg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], " ");
|
||||
|
||||
|
||||
|
||||
if (returnValue != NULL_KEY)
|
||||
|
||||
{
|
||||
|
||||
if (num == 0)
|
||||
|
||||
llMessageLinked(LINK_THIS, 235365342, llList2CSV(params), returnValue);
|
||||
|
||||
else
|
||||
|
||||
llMessageLinked(LINK_THIS, 235365343, llList2CSV(params), returnValue);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
llSleep(40.0); //Something has gone horribly wrong, sleep 40 seconds to clear throttle
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
string checkLanguage(string tempString)
|
||||
|
||||
{
|
||||
|
||||
if (llGetSubString(tempString, 0, 1) == "zh") tempString = "zh-CN";
|
||||
|
||||
else if (tempString == "und") tempString = "el";
|
||||
|
||||
else if (llListFindList(languageCodes, [tempString]) < 0) tempString = "";
|
||||
|
||||
tempString = llGetSubString(tempString, 0, 1);
|
||||
|
||||
return tempString;
|
||||
|
||||
}
|
||||
|
||||
addAgent(key id, string language, integer recheckLangauge)
|
||||
|
||||
{
|
||||
|
||||
integer listPos;
|
||||
|
||||
integer listPosID;
|
||||
|
||||
integer idNum;
|
||||
|
||||
string tempString;
|
||||
|
||||
|
||||
|
||||
listPos = llListFindList(agentsInTranslation, [id]);
|
||||
|
||||
if (listPos < 0)
|
||||
|
||||
{
|
||||
|
||||
while (listPosID >= 0)
|
||||
|
||||
{
|
||||
|
||||
idNum = llRound(llFrand(2000000)) + 1;
|
||||
|
||||
listPosID = llListFindList(agentsInTranslation, [idNum]);
|
||||
|
||||
}
|
||||
|
||||
agentsInTranslation += [id, language, recheckLangauge, idNum];
|
||||
|
||||
llMessageLinked(LINK_THIS, 64562349, language, id);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
agentsInTranslation = llListReplaceList(agentsInTranslation, [language, recheckLangauge], listPos + 1, listPos + 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
string addNewAgent(key id)
|
||||
|
||||
{
|
||||
|
||||
string speakerLanguage;
|
||||
|
||||
|
||||
|
||||
if (llList2Key(llGetObjectDetails(id, [OBJECT_CREATOR]), 0) == NULL_KEY)
|
||||
|
||||
{
|
||||
|
||||
speakerLanguage = checkLanguage(llGetAgentLanguage(id));
|
||||
|
||||
if (speakerLanguage == "")
|
||||
|
||||
{
|
||||
|
||||
speakerLanguage = "en";
|
||||
|
||||
addAgent(id, speakerLanguage, TRUE);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
addAgent(id, speakerLanguage, FALSE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return speakerLanguage;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
key getAgentKey(integer agentID)
|
||||
|
||||
{
|
||||
|
||||
integer listPos = llListFindList(agentsInTranslation, [agentID]);
|
||||
|
||||
if (listPos < 0)
|
||||
|
||||
{
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
return llList2Key(agentsInTranslation, listPos - 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
processHTTPResponse(integer type, string body, list params)
|
||||
|
||||
{
|
||||
|
||||
integer listPos;
|
||||
|
||||
list recepientList;
|
||||
|
||||
key recepientID;
|
||||
|
||||
string recepientLanguage;
|
||||
|
||||
string languagePair;
|
||||
|
||||
key speakerID;
|
||||
|
||||
string speakerName;
|
||||
|
||||
string speakerLanguage;
|
||||
|
||||
string translatedText;
|
||||
|
||||
string tempString;
|
||||
|
||||
integer x;
|
||||
|
||||
integer speakerLanguageReliable;
|
||||
|
||||
float speakerLanguageConfidence;
|
||||
|
||||
list tempList;
|
||||
|
||||
|
||||
|
||||
//===================
|
||||
|
||||
//Process Translation
|
||||
|
||||
//===================
|
||||
|
||||
if (type == 0)
|
||||
|
||||
{
|
||||
|
||||
speakerID = llList2Key(params, 1);
|
||||
|
||||
speakerName = llKey2Name(speakerID);
|
||||
|
||||
if (speakerName == "")
|
||||
|
||||
speakerName = llList2String(llGetObjectDetails(speakerID, [OBJECT_NAME]), 0);
|
||||
|
||||
|
||||
|
||||
recepientList = llParseString2List(llList2String(params, 2), ["@"], []);
|
||||
|
||||
tempList = llParseStringKeepNulls(llList2String(params, 3), ["|"],[]);
|
||||
|
||||
recepientLanguage = llList2String(tempList, 1);
|
||||
|
||||
languagePair = llDumpList2String(tempList, ">>");
|
||||
|
||||
|
||||
|
||||
//Perform Text Cleanup
|
||||
|
||||
x = llSubStringIndex(body, "\",\"detectedSourceLanguage\":\"");
|
||||
|
||||
if (x >= 0)
|
||||
|
||||
{
|
||||
|
||||
translatedText = llGetSubString(body, llSubStringIndex(body, "{\"translatedText\":\"") + 18, x);
|
||||
|
||||
speakerLanguage = checkLanguage(llGetSubString(body, x + 28, llSubStringIndex(body, "\"}, \"responseDetails\":") - 1));
|
||||
|
||||
|
||||
|
||||
listPos = llListFindList(agentsInTranslation, [speakerID]);
|
||||
|
||||
if (listPos >= 0)
|
||||
|
||||
{
|
||||
|
||||
if (speakerLanguage != llList2String(agentsInTranslation, listPos + 1))
|
||||
|
||||
agentsInTranslation = llListReplaceList(agentsInTranslation, [TRUE], listPos + 2, listPos + 2); //Mark for recheck of actual spoken language.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
translatedText = llGetSubString(body, llSubStringIndex(body, "{\"translatedText\":\"") + 18, llSubStringIndex(body, "\"}, \"responseDetails\""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Reverse order if Recepient Language is Hebrew or Arabic
|
||||
|
||||
if ((recepientLanguage == "iw") || (recepientLanguage == "ar"))
|
||||
|
||||
{
|
||||
|
||||
tempString = "";
|
||||
|
||||
for(x = llStringLength(translatedText);x >= 0; x--)
|
||||
|
||||
{
|
||||
|
||||
tempString += llGetSubString(translatedText, x, x);
|
||||
|
||||
}
|
||||
|
||||
translatedText = tempString;
|
||||
|
||||
}
|
||||
|
||||
tempString = speakerName + "(" + languagePair + "): " + translatedText;
|
||||
|
||||
if (showTranslation)
|
||||
|
||||
sendIM(speakerID, tempString);
|
||||
|
||||
for (x = 0; x < llGetListLength(recepientList); x += 1)
|
||||
|
||||
{
|
||||
|
||||
recepientID = getAgentKey(llList2Integer(recepientList, x));
|
||||
@@ -1,83 +0,0 @@
|
||||
// :CATEGORY:Translator
|
||||
// :NAME:Universal_Google_Translator
|
||||
// :AUTHOR:Hank Ramos
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:39:08
|
||||
// :ID:934
|
||||
// :NUM:1341
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// HTTP Handler
|
||||
//
|
||||
// Even though the name of this script is "HTTP Handler", it really just stores the requested translation traffic so that we can match incoming translations from Google with what was requested. Since this takes a lot of memory for storage, this information is kept out of the engine script. When an incoming HTTP response comes in, we fetch the data from here. If the requests didn't come back in a timely fashion, we remove it from the queue.
|
||||
// :CODE:
|
||||
//HTTP Handler
|
||||
|
||||
//Copyright 2006-2009 by Hank Ramos
|
||||
|
||||
|
||||
|
||||
list requestedTranslations;
|
||||
|
||||
list requestedDetections;
|
||||
|
||||
|
||||
|
||||
default
|
||||
|
||||
{
|
||||
|
||||
state_entry()
|
||||
|
||||
{
|
||||
|
||||
llSetTimerEvent(5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
timer()
|
||||
|
||||
{
|
||||
|
||||
integer x;
|
||||
|
||||
list newList;
|
||||
|
||||
float timeElapsed;
|
||||
|
||||
|
||||
|
||||
for (x = 0; x < llGetListLength(requestedDetections); x += 2)
|
||||
|
||||
{
|
||||
|
||||
timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedDetections, x + 1)), 0);
|
||||
|
||||
if (timeElapsed < 60.0)
|
||||
|
||||
newList += llList2List(requestedDetections, x, x + 1);
|
||||
|
||||
}
|
||||
|
||||
requestedDetections = newList;
|
||||
|
||||
newList = [];
|
||||
|
||||
for (x = 0; x < llGetListLength(requestedTranslations); x += 2)
|
||||
|
||||
{
|
||||
|
||||
timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedTranslations, x + 1)), 0);
|
||||
|
||||
if (timeElapsed < 60.0)
|
||||
|
||||
{
|
||||
|
||||
newList += llList2List(requestedTranslations, x, x + 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,665 +0,0 @@
|
||||
// :CATEGORY:Translator
|
||||
// :NAME:Universal_Google_Translator
|
||||
// :AUTHOR:Hank Ramos
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:39:08
|
||||
// :ID:934
|
||||
// :NUM:1342
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// Interface Handler
|
||||
//
|
||||
// This is the interface, or menu-system of the translator. It handles all of the numerous dialogs, language selection, etc. of the translator.
|
||||
// :CODE:
|
||||
//Menu System
|
||||
|
||||
//Copyright 2006-2009 by Hank Ramos
|
||||
|
||||
|
||||
|
||||
//Variables
|
||||
|
||||
integer randomDialogChannel;
|
||||
|
||||
integer lastAttachPoint;
|
||||
|
||||
list detectedAgentKeyList;
|
||||
|
||||
list detectedAgentNameList;
|
||||
|
||||
key agentInDialog;
|
||||
|
||||
integer isInitialized = FALSE;
|
||||
|
||||
list agentsInTranslation;
|
||||
|
||||
integer translatorCount;
|
||||
|
||||
|
||||
|
||||
//Options
|
||||
|
||||
integer groupAccess = FALSE;
|
||||
|
||||
integer autoLanguage = TRUE;
|
||||
|
||||
integer deviceAttached;
|
||||
|
||||
integer enabled = FALSE;
|
||||
|
||||
integer isShowTran = FALSE;
|
||||
|
||||
integer showAgents = TRUE;
|
||||
|
||||
string displayStringMD5;
|
||||
|
||||
integer isMaster = 1;
|
||||
|
||||
integer tranObjects = TRUE;
|
||||
|
||||
|
||||
|
||||
//Constants
|
||||
|
||||
list languages= [
|
||||
|
||||
"Chinese-Simple", "Chinese-Trad", "Croatian",
|
||||
|
||||
"Bulgarian", "Belarusian", "Catlan",
|
||||
|
||||
"Afrikaans", "Albanian", "Arabic",
|
||||
|
||||
|
||||
|
||||
"Filipino", "French", "Galician",
|
||||
|
||||
"Finnish", "English", "Estonian",
|
||||
|
||||
"Czech", "Danish", "Dutch",
|
||||
|
||||
|
||||
|
||||
"Indonesian", "Irish", "Italian",
|
||||
|
||||
"Hindi", "Hungarian", "Icelandic",
|
||||
|
||||
"German", "Greek", "Hebrew",
|
||||
|
||||
|
||||
|
||||
"Maltese", "Norwegian", "Persian",
|
||||
|
||||
"Lithuanian", "Macedonian", "Malay",
|
||||
|
||||
"Japanese", "Korean", "Latvian",
|
||||
|
||||
|
||||
|
||||
"Slovenian", "Spanish", "Swahili",
|
||||
|
||||
"Russian", "Serbian", "Slovak",
|
||||
|
||||
"Polish", "Portuguese", "Romanian",
|
||||
|
||||
|
||||
|
||||
"Yiddish", "\t ", "\t ",
|
||||
|
||||
"Ukrainian", "Vietnamese", "Welsh",
|
||||
|
||||
"Swedish", "Thai", "Turkish"];
|
||||
|
||||
|
||||
|
||||
list languageCodes = [
|
||||
|
||||
"zh-CN", "zh-TW", "hr",
|
||||
|
||||
"bg", "be", "ca",
|
||||
|
||||
"af", "sq", "ar",
|
||||
|
||||
|
||||
|
||||
"tl", "fr", "gl",
|
||||
|
||||
"fi", "en", "et",
|
||||
|
||||
"cs", "da", "nl",
|
||||
|
||||
|
||||
|
||||
"id", "ga", "it",
|
||||
|
||||
"hi", "hu", "is",
|
||||
|
||||
"de", "el", "iw",
|
||||
|
||||
|
||||
|
||||
"mt", "no", "fa",
|
||||
|
||||
"lt", "mk", "ms",
|
||||
|
||||
"ja", "ko", "lv",
|
||||
|
||||
|
||||
|
||||
"sl", "es", "sw",
|
||||
|
||||
"ru", "sr", "sk",
|
||||
|
||||
"pl", "pt-PT", "ro",
|
||||
|
||||
|
||||
|
||||
"yi", "", "",
|
||||
|
||||
"uk", "vi", "cy",
|
||||
|
||||
"sv", "th", "tr"];
|
||||
|
||||
|
||||
|
||||
//Functions
|
||||
|
||||
//Takes in the offsets, and the attach point
|
||||
|
||||
vector fn_makePos(integer attach_point, vector offset) {
|
||||
|
||||
if ((attach_point == 31) || (attach_point == 35)) { //center 2 & center
|
||||
|
||||
return <0,0,0>;
|
||||
|
||||
} else if (attach_point == 32) { // Top right
|
||||
|
||||
return <offset.x, offset.y, offset.z * -1>;
|
||||
|
||||
} else if (attach_point == 33) { // Top
|
||||
|
||||
return <offset.x, 0, offset.z * -1>;
|
||||
|
||||
} else if (attach_point == 34) { // Top Left
|
||||
|
||||
return <offset.x, offset.y * -1, offset.z * -1>;
|
||||
|
||||
} else if (attach_point == 36) { // Bottom Left
|
||||
|
||||
return <offset.x, offset.y * -1 , offset.z>;
|
||||
|
||||
} else if (attach_point == 37) { // Bottom
|
||||
|
||||
return <offset.x, 0, offset.z>;
|
||||
|
||||
} else if (attach_point == 38) { // Bottom Right - Baseline
|
||||
|
||||
return offset;
|
||||
|
||||
} else { //Not a HUD point? Then return it's current pos
|
||||
|
||||
return llGetLocalPos();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateDisplay()
|
||||
|
||||
{
|
||||
|
||||
string tempString;
|
||||
|
||||
integer listLength;
|
||||
|
||||
integer x;
|
||||
|
||||
string agentName;
|
||||
|
||||
|
||||
|
||||
if (isInitialized == FALSE) return;
|
||||
|
||||
tempString = "Universal Translator";
|
||||
|
||||
if (isMaster != 1)
|
||||
|
||||
tempString += " (Link-" + (string)(translatorCount + 1) + ")";
|
||||
|
||||
tempString += "\n===============";
|
||||
|
||||
|
||||
|
||||
if (enabled)
|
||||
|
||||
{
|
||||
|
||||
listLength = llGetListLength(agentsInTranslation);
|
||||
|
||||
if (((showAgents) && (listLength <= 40)) && (listLength != 0))
|
||||
|
||||
{
|
||||
|
||||
for (x = 0; x < listLength; x += 4)
|
||||
|
||||
{
|
||||
|
||||
agentName = llList2String(llGetObjectDetails(llList2Key(agentsInTranslation, x), [OBJECT_NAME]), 0);
|
||||
|
||||
if (llStringLength(agentName) > 25)
|
||||
|
||||
agentName = llGetSubString(agentName, 0, 24);
|
||||
|
||||
if (agentName != "")
|
||||
|
||||
tempString += "\n" + agentName + "(" + llList2String(agentsInTranslation, x + 1) + ")";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
tempString += "\n# Agents Translated: " + (string)llRound(listLength/3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
tempString += "\n>> Disabled <<";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (llMD5String(tempString, 0) != displayStringMD5)
|
||||
|
||||
{
|
||||
|
||||
displayStringMD5 = llMD5String(tempString, 0);
|
||||
|
||||
llSetText(tempString, <1,1,1>, 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
showMainMenu(key id)
|
||||
|
||||
{
|
||||
|
||||
if (isInitialized == FALSE) return;
|
||||
|
||||
integer avatarParticipating;
|
||||
|
||||
list buttonList = ["Language", "Help"];
|
||||
|
||||
string dialogMsg = "Main Menu\nLANGUAGE: manually choose your source language. Target languages are detected automatically\nHELP: get help notecard";
|
||||
|
||||
buttonList += "FREE Copy";
|
||||
|
||||
dialogMsg += "\nFREE COPY: receive FREE copy of Universal Translator.";
|
||||
|
||||
|
||||
|
||||
if (llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [(string)id]) + 1) != "xx")
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Opt-Out";
|
||||
|
||||
dialogMsg += "\nOPT-OUT: disable receipt of translations";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Opt-In";
|
||||
|
||||
dialogMsg += "\nOPT-IN: join the translations";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (id == llGetOwner())
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Donate";
|
||||
|
||||
dialogMsg += "\nDONATE: donate L$ to the developer of Universal Translator.";
|
||||
|
||||
}
|
||||
|
||||
if ((id == llGetOwner()) || ((groupAccess) && (llSameGroup(id))))
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Reset";
|
||||
|
||||
buttonList += "Options";
|
||||
|
||||
buttonList += "Send Copy";
|
||||
|
||||
dialogMsg += "\nSEND COPY: send FREE copy of Universal Translator.";
|
||||
|
||||
|
||||
|
||||
if (enabled)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Disable";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Enable";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
dialogMsg += "\nRESET: reset all scripts in translator";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
llDialog(id, dialogMsg, buttonList, randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
showOptionsMenu(key id)
|
||||
|
||||
{
|
||||
|
||||
integer avatarParticipating;
|
||||
|
||||
list buttonList = [];
|
||||
|
||||
string dialogMsg = "Options Menu.";
|
||||
|
||||
if (id == llGetOwner())
|
||||
|
||||
{
|
||||
|
||||
if (groupAccess)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Group OFF";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Group ON";
|
||||
|
||||
}
|
||||
|
||||
dialogMsg += "\nGROUP: allow group members to admin.";
|
||||
|
||||
}
|
||||
|
||||
if ((id == llGetOwner()) || ((groupAccess) && (llSameGroup(id))))
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Main Menu";
|
||||
|
||||
if (!deviceAttached)
|
||||
|
||||
{
|
||||
|
||||
if (autoLanguage)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Scan OFF";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Scan ON";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dialogMsg += "\nSCAN: scan for Avatars and automatically add to translation matrix.";
|
||||
|
||||
|
||||
|
||||
if (isShowTran)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Echo OFF";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Echo ON";
|
||||
|
||||
}
|
||||
|
||||
dialogMsg += "\nECHO: show translations of your chat sent to others.";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (tranObjects)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Objects OFF";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Objects ON";
|
||||
|
||||
}
|
||||
|
||||
dialogMsg += "\nOBJECTS: translate chat of scripted objects";
|
||||
|
||||
|
||||
|
||||
if (showAgents)
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Agents OFF";
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
buttonList += "Agents ON";
|
||||
|
||||
}
|
||||
|
||||
dialogMsg += "\AGENTS: show list of agents translated.";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
llDialog(id, dialogMsg, buttonList, randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
showLanguageDialog1(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language...", ["\t", "\t", ">> NEXT"] + llList2List(languages, 0, 8), randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
showLanguageDialog2(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language..", ["<< BACK", "\t ", ">> NEXT "] + llList2List(languages, 9, 17), randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
showLanguageDialog3(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 18, 26), randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
showLanguageDialog4(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 27, 35), randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
showLanguageDialog5(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 36, 44), randomDialogChannel);
|
||||
|
||||
}showLanguageDialog6(key id)
|
||||
|
||||
{
|
||||
|
||||
llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", "\t "] + llList2List(languages, 45, 53), randomDialogChannel);
|
||||
|
||||
}
|
||||
|
||||
processListen(string name, key id, string message)
|
||||
|
||||
{
|
||||
|
||||
key listenKey;
|
||||
|
||||
|
||||
|
||||
if (llListFindList(languages, [message]) > -1) //Language Selected in Dialog
|
||||
|
||||
{
|
||||
|
||||
if (message != "") llMessageLinked(LINK_THIS, 9384610, llList2String(languageCodes, llListFindList(languages, [message])), id);
|
||||
|
||||
}
|
||||
|
||||
else if (llToLower(message) == "help")
|
||||
|
||||
{
|
||||
|
||||
llGiveInventory(id, "Universal Translator Help");
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Main Menu")
|
||||
|
||||
{
|
||||
|
||||
showMainMenu(id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Options")
|
||||
|
||||
{
|
||||
|
||||
showOptionsMenu(id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Language")
|
||||
|
||||
{
|
||||
|
||||
showLanguageDialog1(id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Opt-In")
|
||||
|
||||
{
|
||||
|
||||
showLanguageDialog1(id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Opt-Out")
|
||||
|
||||
{
|
||||
|
||||
llMessageLinked(LINK_THIS, 9384610, "xx", id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "FREE Copy")
|
||||
|
||||
{
|
||||
|
||||
llMessageLinked(LINK_THIS, 9455209, llKey2Name(id), id);
|
||||
|
||||
}
|
||||
|
||||
if (id == llGetOwner())
|
||||
|
||||
{
|
||||
|
||||
if (message == "Group ON")
|
||||
|
||||
{
|
||||
|
||||
groupAccess = TRUE;
|
||||
|
||||
showMainMenu(id);
|
||||
|
||||
}
|
||||
|
||||
else if (message == "Group OFF")
|
||||
|
||||
{
|
||||
|
||||
groupAccess = FALSE;
|
||||
|
||||
showMainMenu(id);
|
||||
@@ -1,7 +0,0 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|08 Sep 2013 03:49:08 -0000
|
||||
vti_extenderversion:SR|12.0.0.6211
|
||||
vti_backlinkinfo:VX|
|
||||
vti_author:SR|alien\\fred
|
||||
vti_modifiedby:SR|alien\\fred
|
||||
vti_timecreated:TR|18 Sep 2013 20:39:08 -0000
|
||||
@@ -1,7 +0,0 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|08 Sep 2013 03:49:08 -0000
|
||||
vti_extenderversion:SR|12.0.0.6211
|
||||
vti_backlinkinfo:VX|
|
||||
vti_author:SR|alien\\fred
|
||||
vti_modifiedby:SR|alien\\fred
|
||||
vti_timecreated:TR|18 Sep 2013 20:39:08 -0000
|
||||
@@ -1,7 +0,0 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|08 Sep 2013 03:49:08 -0000
|
||||
vti_extenderversion:SR|12.0.0.6211
|
||||
vti_backlinkinfo:VX|
|
||||
vti_author:SR|alien\\fred
|
||||
vti_modifiedby:SR|alien\\fred
|
||||
vti_timecreated:TR|18 Sep 2013 20:39:08 -0000
|
||||
@@ -1,10 +0,0 @@
|
||||
<Project name="Universal_Google_Translator" guid="D8301CB0-6C00-1014-B904-200204C60A89">
|
||||
<Object name="Object" guid="D8301D99-6C00-1014-B904-200204C60A89">
|
||||
<Script name="Universal_Google_Translator_1.lsl" guid="D830F61E-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
<Script name="Universal_Google_Translator_2.lsl" guid="D831FEF5-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
<Script name="Universal_Google_Translator_3.lsl" guid="D8321B60-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
</Object>
|
||||
</Project>
|
||||
@@ -1,6 +0,0 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|17 Aug 2013 23:32:36 -0000
|
||||
vti_extenderversion:SR|12.0.0.0
|
||||
vti_cacheddtm:TX|17 Aug 2013 23:32:36 -0000
|
||||
vti_filesize:IR|513
|
||||
vti_backlinkinfo:VX|
|
||||
Reference in New Issue
Block a user