removed useless _ folders
This commit is contained in:
3
Open_BabelFish_Translator/Open_BabelFish_Translator.sol
Normal file
3
Open_BabelFish_Translator/Open_BabelFish_Translator.sol
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution name="Open_BabelFish_Translator">
|
||||
<Project name="Open_BabelFish_Translator" path="Open_BabelFish_Translator\Open_BabelFish_Translator.prj" active="true"/>
|
||||
</Solution>
|
||||
@@ -0,0 +1,172 @@
|
||||
// :CATEGORY:Translator
|
||||
// :NAME:Open_BabelFish_Translator
|
||||
// :AUTHOR:falados
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:38:59
|
||||
// :ID:587
|
||||
// :NUM:804
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// Open BabelFish Query
|
||||
// :CODE:
|
||||
// This file is part of Open Babel Fish.
|
||||
|
||||
//
|
||||
|
||||
// Open Babel Fish is free software: you can redistribute it and/or modify
|
||||
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
// (at your option) any later version.
|
||||
|
||||
//
|
||||
|
||||
// Open Babel Fish is distributed in the hope that it will be useful,
|
||||
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
|
||||
// GNU General Public License for more details.
|
||||
|
||||
//
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
|
||||
// along with Open Babel Fish. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
//
|
||||
|
||||
// Author: Falados Kapuskas
|
||||
|
||||
// Date: 3/25/2008
|
||||
|
||||
// Version: 1.3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string URL;
|
||||
|
||||
|
||||
|
||||
key owner;
|
||||
|
||||
integer ENCODE = 0;
|
||||
|
||||
integer DECODE = 1;
|
||||
|
||||
string MY_NAME = "Babel Fish";
|
||||
|
||||
|
||||
|
||||
//Rate Limit Queueing
|
||||
|
||||
key gDataserverRequest;
|
||||
|
||||
float rate = 1.0; //Every second
|
||||
|
||||
integer MessageQueue_length;
|
||||
|
||||
list MessageQueue_lp;
|
||||
|
||||
list MessageQueue_data;
|
||||
|
||||
list MessageQueue_name;
|
||||
|
||||
|
||||
|
||||
//Translation Stuff
|
||||
|
||||
list trans_requests;
|
||||
|
||||
list http_parm = [
|
||||
|
||||
HTTP_METHOD, "POST",
|
||||
|
||||
HTTP_MIMETYPE,"application/x-www-form-urlencoded"
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
//Function: queue_message
|
||||
|
||||
//Description: Queues a message for translation later
|
||||
|
||||
queue_message(string data, string langpair, string name) {
|
||||
|
||||
//Hack for english to english
|
||||
|
||||
if( langpair == "en|en" ) {
|
||||
|
||||
llSetObjectName(name);
|
||||
|
||||
llOwnerSay(data);
|
||||
|
||||
} else {
|
||||
|
||||
++MessageQueue_length;
|
||||
|
||||
MessageQueue_lp += langpair;
|
||||
|
||||
MessageQueue_data += data;
|
||||
|
||||
MessageQueue_name += name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Function: send_queued_message
|
||||
|
||||
//Description: Sends the first message on the queue
|
||||
|
||||
send_queued_message() {
|
||||
|
||||
if( MessageQueue_length > 0 )
|
||||
|
||||
{
|
||||
|
||||
//Prepare the request
|
||||
|
||||
string request = translate_text( llList2String(MessageQueue_data,0), llList2String(MessageQueue_lp,0) );
|
||||
|
||||
string translate_name = llList2String(MessageQueue_name,0);
|
||||
|
||||
|
||||
|
||||
//Remove the queued item
|
||||
|
||||
MessageQueue_lp = llDeleteSubList(MessageQueue_lp,0,0);
|
||||
|
||||
MessageQueue_data = llDeleteSubList(MessageQueue_data,0,0);
|
||||
|
||||
MessageQueue_name = llDeleteSubList(MessageQueue_name,0,0);
|
||||
|
||||
|
||||
|
||||
//Fire it
|
||||
|
||||
trans_requests += [llHTTPRequest( URL, http_parm, request ),translate_name];
|
||||
|
||||
--MessageQueue_length;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Function: translate_text
|
||||
|
||||
//Description: This funciton simply assemples the proper POST data that must
|
||||
|
||||
//be sent to the php script. It returns that data
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
// :CATEGORY:Translator
|
||||
// :NAME:Open_BabelFish_Translator
|
||||
// :AUTHOR:falados
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:38:59
|
||||
// :ID:587
|
||||
// :NUM:805
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// Open BabelFish
|
||||
// :CODE:
|
||||
// This file is part of Open Babel Fish.
|
||||
|
||||
//
|
||||
|
||||
// Open Babel Fish is free software: you can redistribute it and/or modify
|
||||
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
// (at your option) any later version.
|
||||
|
||||
//
|
||||
|
||||
// Open Babel Fish is distributed in the hope that it will be useful,
|
||||
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
|
||||
// GNU General Public License for more details.
|
||||
|
||||
//
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
|
||||
// along with Open Babel Fish. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
//
|
||||
|
||||
// Author: Falados Kapuskas
|
||||
|
||||
// Date: 7/20/2008
|
||||
|
||||
// Version: 1.4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//CONSTANT PARAMETERS
|
||||
|
||||
|
||||
|
||||
float AUTO_TRANSLATE_POLL_TIME = 40.0; //Amount of time between auto-translation announcements
|
||||
|
||||
string NATIVE_LANGUAGE;
|
||||
|
||||
integer AUTO;
|
||||
|
||||
string MY_NAME = "Babel Fish";
|
||||
|
||||
|
||||
|
||||
integer LANGUAGE_ANNOUNCE = 234235; //Please keep this standard amongs all revisions
|
||||
|
||||
//If you dont, then the auto-detect language wont work for you.
|
||||
|
||||
|
||||
|
||||
integer CONTROL_CHANNEL = 55; //This is the channel on which you chat commands
|
||||
|
||||
//This can be changed to whatever
|
||||
|
||||
|
||||
|
||||
//Globals
|
||||
|
||||
key owner;
|
||||
|
||||
string PARTIAL; //Partial name for 'tr' command
|
||||
|
||||
integer FIRST = TRUE; //First run of the translator state
|
||||
|
||||
string USAGE;
|
||||
|
||||
integer master_listen;
|
||||
|
||||
|
||||
|
||||
//Listeners
|
||||
|
||||
list listeners = [];
|
||||
|
||||
|
||||
|
||||
//Function: translate
|
||||
|
||||
//Description: Sends a message out for translation.
|
||||
|
||||
translate(string data, string langpair, string name) {
|
||||
|
||||
llMessageLinked(LINK_THIS,-10,data,langpair + "," + name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Function: add_listener
|
||||
|
||||
//Description: Adds a listener to the translate list by name.
|
||||
|
||||
add_listener( string name, string pair ) {
|
||||
|
||||
if( pair == NATIVE_LANGUAGE + "|" + NATIVE_LANGUAGE ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
integer i = llListFindList( listeners, [name,pair]);
|
||||
|
||||
integer j = llListFindList( listeners, [name]);
|
||||
|
||||
if( j == -1 ) {
|
||||
|
||||
listeners += [name,pair];
|
||||
|
||||
string text;
|
||||
|
||||
//Tell the user a new listener was added
|
||||
|
||||
if( name == llKey2Name(owner) ) {
|
||||
|
||||
text = "Your language changed";
|
||||
|
||||
} else {
|
||||
|
||||
text = name + " added";
|
||||
|
||||
}
|
||||
|
||||
translate(
|
||||
|
||||
text,
|
||||
|
||||
"en|" + NATIVE_LANGUAGE,
|
||||
|
||||
MY_NAME
|
||||
|
||||
);
|
||||
|
||||
} else if( i == -1) {
|
||||
|
||||
listeners = llListReplaceList( listeners , [pair] , j+1 , j+1 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Funciton: remove_name
|
||||
|
||||
//Description: Remove a listener from the list
|
||||
|
||||
remove_name( string name ){
|
||||
|
||||
integer i = llListFindList( listeners , [name]);
|
||||
|
||||
if( i != -1 ) {
|
||||
|
||||
translate(
|
||||
|
||||
name + " removed",
|
||||
|
||||
"en|" + NATIVE_LANGUAGE,
|
||||
|
||||
MY_NAME
|
||||
|
||||
);
|
||||
|
||||
listeners = llDeleteSubList( listeners, i,i+1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------ STATES ------- //
|
||||
|
||||
|
||||
|
||||
//Setup State
|
||||
|
||||
default
|
||||
|
||||
{
|
||||
|
||||
on_rez(integer p) { if(llGetOwner() != owner) llResetScript(); }
|
||||
|
||||
state_entry()
|
||||
|
||||
{
|
||||
|
||||
owner = llGetOwner();
|
||||
|
||||
llMessageLinked(LINK_THIS,-3,"setup","root");
|
||||
|
||||
}
|
||||
|
||||
link_message(integer sender_number, integer number, string message, key id)
|
||||
|
||||
{
|
||||
|
||||
if( number == 0 && message == "init" && id == "dialog" ) {
|
||||
|
||||
llSetTimerEvent(0.0);
|
||||
|
||||
state setup;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timer() {
|
||||
|
||||
llMessageLinked(LINK_THIS,-3,"setup","root");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//State: setup
|
||||
|
||||
//Description: Attempts to retrieve the native langauge of the current user
|
||||
|
||||
state setup {
|
||||
|
||||
on_rez(integer p) {llResetScript();}
|
||||
|
||||
state_entry() {
|
||||
|
||||
llMessageLinked(LINK_THIS,0,"ask_lang",owner);
|
||||
|
||||
}
|
||||
|
||||
link_message(integer sender_number, integer number, string message, key id)
|
||||
|
||||
{
|
||||
|
||||
if( number == -1 && id == owner) {
|
||||
|
||||
NATIVE_LANGUAGE = message;
|
||||
|
||||
state translator;
|
||||
|
||||
}
|
||||
|
||||
if( number == -4 && message == "timeout" && id == owner ) {
|
||||
|
||||
llMessageLinked(LINK_THIS,0,"ask_lang",owner);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//State: translator(_loop)
|
||||
|
||||
//Description: This is the main loop where all the magic happens.
|
||||
|
||||
//This state accepts user commands, adds listeners, and does the translations
|
||||
|
||||
//The main HTTP request line is in here.
|
||||
|
||||
//This state also does the setup to determining the user's native language
|
||||
|
||||
//The NATIVE_LANGUAGE variable is extremely important when it comes to most
|
||||
|
||||
//functions, especially automatic translation.
|
||||
|
||||
state translator_loop { state_entry() { state translator;}}
|
||||
|
||||
state translator {
|
||||
|
||||
on_rez(integer p) { if(llGetOwner() != owner) llResetScript(); }
|
||||
|
||||
state_entry() {
|
||||
|
||||
//If this is the first run through, say the usage line
|
||||
|
||||
if(FIRST) {
|
||||
|
||||
string tr = "|";
|
||||
|
||||
if(NATIVE_LANGUAGE == "en") tr = "";
|
||||
|
||||
//TODO: This usage line should be updated when new functions come out
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "autotrans" + tr + " <name> to automatically translate someone.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "translate" + tr + " <name> to ask for translation.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "remove" + tr + " <name> to remove a translated person.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "remove all" + tr + " to remove all translated people.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "speak" + tr + " to speak another language through " + MY_NAME;
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "list" + tr + " to display the people who are now translated.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "help" + tr + " to display this message.";
|
||||
|
||||
USAGE += "\nType /" + (string)CONTROL_CHANNEL + " " + tr + "reset" + tr + " to reset Open Babel Fish.";
|
||||
|
||||
|
||||
|
||||
translate(
|
||||
|
||||
USAGE,
|
||||
|
||||
"en|" + NATIVE_LANGUAGE,
|
||||
|
||||
MY_NAME
|
||||
|
||||
);
|
||||
|
||||
FIRST = FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Listen for Auto-Language Detection
|
||||
@@ -0,0 +1,8 @@
|
||||
<Project name="Open_BabelFish_Translator" guid="D6D20383-6C00-1014-B904-200204C60A89">
|
||||
<Object name="Object" guid="D6D2047D-6C00-1014-B904-200204C60A89">
|
||||
<Script name="Open_BabelFish_Translator_1.lsl" guid="D6D2418E-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
<Script name="Open_BabelFish_Translator_2.lsl" guid="D6D26448-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
</Object>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user