Revert "This works for now. Need to do more testing."
This reverts commit c6d6eed7d3.
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<llsd>
|
<llsd>
|
||||||
<map>
|
<map>
|
||||||
<key>Include</key>
|
<key>Include</key>
|
||||||
<array>
|
<array>
|
||||||
<string>settings_ascent.xml</string>
|
<string>settings_ascent.xml</string>
|
||||||
<string>settings_ascent_coa.xml</string>
|
<string>settings_ascent_coa.xml</string>
|
||||||
<string>settings_sh.xml</string>
|
<string>settings_sh.xml</string>
|
||||||
<string>settings_rlv.xml</string>
|
<string>settings_rlv.xml</string>
|
||||||
</array>
|
</array>
|
||||||
<key>SianaRenderDeferredInvisiprim</key>
|
|
||||||
<map>
|
<key>SianaRenderDeferredInvisiprim</key>
|
||||||
|
<map>
|
||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
<string>Support invisiprims in deferred mode</string>
|
<string>Support invisiprims in deferred mode</string>
|
||||||
<key>Persist</key>
|
<key>Persist</key>
|
||||||
@@ -7524,45 +7525,12 @@
|
|||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
<string>Translate incoming chat messages</string>
|
<string>Translate incoming chat messages</string>
|
||||||
<key>Persist</key>
|
<key>Persist</key>
|
||||||
<integer>1</integer>
|
<integer>0</integer>
|
||||||
<key>Type</key>
|
<key>Type</key>
|
||||||
<string>Boolean</string>
|
<string>Boolean</string>
|
||||||
<key>Value</key>
|
<key>Value</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</map>
|
</map>
|
||||||
<key>TranslationService</key>
|
|
||||||
<map>
|
|
||||||
<key>Comment</key>
|
|
||||||
<string>Translation API to use. (google|bing)</string>
|
|
||||||
<key>Persist</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>Type</key>
|
|
||||||
<string>String</string>
|
|
||||||
<key>Value</key>
|
|
||||||
<string>bing</string>
|
|
||||||
</map>
|
|
||||||
<key>GoogleTranslateAPIKey</key>
|
|
||||||
<map>
|
|
||||||
<key>Comment</key>
|
|
||||||
<string>Google Translate API key</string>
|
|
||||||
<key>Persist</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>Type</key>
|
|
||||||
<string>String</string>
|
|
||||||
<key>Value</key>
|
|
||||||
<string></string>
|
|
||||||
</map>
|
|
||||||
<key>BingTranslateAPIKey</key>
|
|
||||||
<map>
|
|
||||||
<key>Comment</key>
|
|
||||||
<string>Bing AppID to use with the Microsoft Translator API</string>
|
|
||||||
<key>Persist</key>
|
|
||||||
<integer>1</integer>
|
|
||||||
<key>Type</key>
|
|
||||||
<string>String</string>
|
|
||||||
<key>Value</key>
|
|
||||||
<string></string>
|
|
||||||
</map>
|
|
||||||
<key>LastFeatureVersion</key>
|
<key>LastFeatureVersion</key>
|
||||||
<map>
|
<map>
|
||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
|
|||||||
@@ -2,401 +2,136 @@
|
|||||||
* @file lltranslate.cpp
|
* @file lltranslate.cpp
|
||||||
* @brief Functions for translating text via Google Translate.
|
* @brief Functions for translating text via Google Translate.
|
||||||
*
|
*
|
||||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
* $LicenseInfo:firstyear=2009&license=viewergpl$
|
||||||
* Second Life Viewer Source Code
|
*
|
||||||
* Copyright (C) 2010, Linden Research, Inc.
|
* Copyright (c) 2009, Linden Research, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* Second Life Viewer Source Code
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||||
* License as published by the Free Software Foundation;
|
* to you under the terms of the GNU General Public License, version 2.0
|
||||||
* version 2.1 of the License only.
|
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||||
*
|
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||||
* This library is distributed in the hope that it will be useful,
|
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
*
|
||||||
* Lesser General Public License for more details.
|
* There are special exceptions to the terms and conditions of the GPL as
|
||||||
*
|
* it is applied to this Source Code. View the full text of the exception
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||||
* License along with this library; if not, write to the Free Software
|
* online at
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||||
*
|
*
|
||||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
* By copying, modifying or distributing this software, you acknowledge
|
||||||
* $/LicenseInfo$
|
* that you have read and understood your obligations described above,
|
||||||
*/
|
* and agree to abide by those obligations.
|
||||||
|
*
|
||||||
|
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||||
|
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||||
|
* COMPLETENESS OR PERFORMANCE.
|
||||||
|
* $/LicenseInfo$
|
||||||
|
*/
|
||||||
|
|
||||||
#include "llviewerprecompiledheaders.h"
|
#include "llviewerprecompiledheaders.h"
|
||||||
|
|
||||||
#include "lltranslate.h"
|
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
#include "llbufferstream.h"
|
#include "llbufferstream.h"
|
||||||
#include "lltrans.h"
|
#include "lltranslate.h"
|
||||||
#include "llui.h"
|
#include "llui.h"
|
||||||
#include "llviewercontrol.h"
|
#include "sgversion.h"
|
||||||
#include "llweb.h"
|
#include "llweb.h"
|
||||||
|
|
||||||
#include "sgversion.h"
|
// <edit>
|
||||||
|
#include "llviewercontrol.h"
|
||||||
|
// </edit>
|
||||||
|
|
||||||
#include "jsoncpp/reader.h"
|
// These two are concatenated with the language specifiers to form a complete Google Translate URL
|
||||||
|
const char* LLTranslate::m_GoogleURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=";
|
||||||
|
const char* LLTranslate::m_GoogleLangSpec = "&langpair=";
|
||||||
|
float LLTranslate::m_GoogleTimeout = 10;
|
||||||
|
|
||||||
// virtual
|
LLSD LLTranslate::m_Header;
|
||||||
void LLGoogleTranslationHandler::getTranslateURL(
|
// These constants are for the GET header.
|
||||||
std::string &url,
|
const char* LLTranslate::m_AcceptHeader = "Accept";
|
||||||
const std::string &from_lang,
|
const char* LLTranslate::m_AcceptType = "text/plain";
|
||||||
const std::string &to_lang,
|
const char* LLTranslate::m_AgentHeader = "User-Agent";
|
||||||
const std::string &text) const
|
|
||||||
|
// These constants are in the JSON returned from Google
|
||||||
|
const char* LLTranslate::m_GoogleData = "responseData";
|
||||||
|
const char* LLTranslate::m_GoogleTranslation = "translatedText";
|
||||||
|
const char* LLTranslate::m_GoogleLanguage = "detectedSourceLanguage";
|
||||||
|
|
||||||
|
//static
|
||||||
|
void LLTranslate::translateMessage(LLHTTPClient::ResponderPtr &result, const std::string &fromLang, const std::string &toLang, const std::string &mesg)
|
||||||
{
|
{
|
||||||
url = std::string("https://www.googleapis.com/language/translate/v2?key=")
|
std::string url;
|
||||||
+ getAPIKey() + "&q=" + LLURI::escape(text) + "&target=" + to_lang;
|
getTranslateUrl(url, fromLang, toLang, mesg);
|
||||||
if (!from_lang.empty())
|
|
||||||
|
//<edit>
|
||||||
|
std::string user_agent = gCurrentVersion;
|
||||||
|
//</edit>
|
||||||
|
|
||||||
|
if (!m_Header.size())
|
||||||
{
|
{
|
||||||
url += "&source=" + from_lang;
|
m_Header.insert(m_AcceptHeader, LLSD(m_AcceptType));
|
||||||
}
|
m_Header.insert(m_AgentHeader, LLSD(user_agent));
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
void LLGoogleTranslationHandler::getKeyVerificationURL(
|
|
||||||
std::string& url,
|
|
||||||
const std::string& key) const
|
|
||||||
{
|
|
||||||
url = std::string("https://www.googleapis.com/language/translate/v2/languages?key=")
|
|
||||||
+ key + "&target=en";
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
bool LLGoogleTranslationHandler::parseResponse(
|
|
||||||
int& status,
|
|
||||||
const std::string& body,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang,
|
|
||||||
std::string& err_msg) const
|
|
||||||
{
|
|
||||||
Json::Value root;
|
|
||||||
Json::Reader reader;
|
|
||||||
|
|
||||||
if (!reader.parse(body, root))
|
|
||||||
{
|
|
||||||
err_msg = reader.getFormatedErrorMessages();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!root.isObject()) // empty response? should not happen
|
LLHTTPClient::get(url, result, m_Header, m_GoogleTimeout);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != STATUS_OK)
|
|
||||||
{
|
|
||||||
// Request failed. Extract error message from the response.
|
|
||||||
parseErrorResponse(root, status, err_msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request succeeded, extract translation from the response.
|
|
||||||
return parseTranslation(root, translation, detected_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
bool LLGoogleTranslationHandler::isConfigured() const
|
|
||||||
{
|
|
||||||
return !getAPIKey().empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void LLGoogleTranslationHandler::parseErrorResponse(
|
|
||||||
const Json::Value& root,
|
|
||||||
int& status,
|
|
||||||
std::string& err_msg)
|
|
||||||
{
|
|
||||||
const Json::Value& error = root.get("error", 0);
|
|
||||||
if (!error.isObject() || !error.isMember("message") || !error.isMember("code"))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_msg = error["message"].asString();
|
|
||||||
status = error["code"].asInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
bool LLGoogleTranslationHandler::parseTranslation(
|
|
||||||
const Json::Value& root,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang)
|
|
||||||
{
|
|
||||||
// JsonCpp is prone to aborting the program on failed assertions,
|
|
||||||
// so be super-careful and verify the response format.
|
|
||||||
const Json::Value& data = root.get("data", 0);
|
|
||||||
if (!data.isObject() || !data.isMember("translations"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Json::Value& translations = data["translations"];
|
|
||||||
if (!translations.isArray() || translations.size() == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Json::Value& first = translations[0U];
|
|
||||||
if (!first.isObject() || !first.isMember("translatedText"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
translation = first["translatedText"].asString();
|
|
||||||
detected_lang = first.get("detectedSourceLanguage", "").asString();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
std::string LLGoogleTranslationHandler::getAPIKey()
|
|
||||||
{
|
|
||||||
return gSavedSettings.getString("GoogleTranslateAPIKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
void LLBingTranslationHandler::getTranslateURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &from_lang,
|
|
||||||
const std::string &to_lang,
|
|
||||||
const std::string &text) const
|
|
||||||
{
|
|
||||||
url = std::string("http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=")
|
|
||||||
+ getAPIKey() + "&text=" + LLURI::escape(text) + "&to=" + to_lang;
|
|
||||||
if (!from_lang.empty())
|
|
||||||
{
|
|
||||||
url += "&from=" + from_lang;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
void LLBingTranslationHandler::getKeyVerificationURL(
|
|
||||||
std::string& url,
|
|
||||||
const std::string& key) const
|
|
||||||
{
|
|
||||||
url = std::string("http://api.microsofttranslator.com/v2/Http.svc/GetLanguagesForTranslate?appId=")
|
|
||||||
+ key;
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
bool LLBingTranslationHandler::parseResponse(
|
|
||||||
int& status,
|
|
||||||
const std::string& body,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang,
|
|
||||||
std::string& err_msg) const
|
|
||||||
{
|
|
||||||
if (status != STATUS_OK)
|
|
||||||
{
|
|
||||||
static const std::string MSG_BEGIN_MARKER = "Message: ";
|
|
||||||
size_t begin = body.find(MSG_BEGIN_MARKER);
|
|
||||||
if (begin != std::string::npos)
|
|
||||||
{
|
|
||||||
begin += MSG_BEGIN_MARKER.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
begin = 0;
|
|
||||||
err_msg.clear();
|
|
||||||
}
|
|
||||||
size_t end = body.find("</p>", begin);
|
|
||||||
err_msg = body.substr(begin, end-begin);
|
|
||||||
LLStringUtil::replaceString(err_msg, "
", ""); // strip CR
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sample response: <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hola</string>
|
|
||||||
size_t begin = body.find(">");
|
|
||||||
if (begin == std::string::npos || begin >= (body.size() - 1))
|
|
||||||
{
|
|
||||||
begin = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t end = body.find("</string>", begin);
|
|
||||||
|
|
||||||
detected_lang = ""; // unsupported by this API
|
|
||||||
translation = body.substr(begin, end-begin);
|
|
||||||
LLStringUtil::replaceString(translation, "
", ""); // strip CR
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
bool LLBingTranslationHandler::isConfigured() const
|
|
||||||
{
|
|
||||||
return !getAPIKey().empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
std::string LLBingTranslationHandler::getAPIKey()
|
|
||||||
{
|
|
||||||
return gSavedSettings.getString("BingTranslateAPIKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
LLTranslate::TranslationReceiver::TranslationReceiver(const std::string& from_lang, const std::string& to_lang)
|
|
||||||
: mFromLang(from_lang)
|
|
||||||
, mToLang(to_lang)
|
|
||||||
, mHandler(LLTranslate::getPreferredHandler())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
void LLTranslate::TranslationReceiver::completedRaw(
|
|
||||||
U32 http_status,
|
|
||||||
const std::string& reason,
|
|
||||||
const LLChannelDescriptors& channels,
|
|
||||||
const LLIOPipe::buffer_ptr_t& buffer)
|
|
||||||
{
|
|
||||||
LLBufferStream istr(channels, buffer.get());
|
|
||||||
std::stringstream strstrm;
|
|
||||||
strstrm << istr.rdbuf();
|
|
||||||
|
|
||||||
const std::string body = strstrm.str();
|
|
||||||
std::string translation, detected_lang, err_msg;
|
|
||||||
int status = http_status;
|
|
||||||
LL_DEBUGS("Translate") << "HTTP status: " << status << " " << reason << LL_ENDL;
|
|
||||||
LL_DEBUGS("Translate") << "Response body: " << body << LL_ENDL;
|
|
||||||
if (mHandler.parseResponse(status, body, translation, detected_lang, err_msg))
|
|
||||||
{
|
|
||||||
// Fix up the response
|
|
||||||
LLStringUtil::replaceString(translation, "<", "<");
|
|
||||||
LLStringUtil::replaceString(translation, ">",">");
|
|
||||||
LLStringUtil::replaceString(translation, ""","\"");
|
|
||||||
LLStringUtil::replaceString(translation, "'","'");
|
|
||||||
LLStringUtil::replaceString(translation, "&","&");
|
|
||||||
LLStringUtil::replaceString(translation, "'","'");
|
|
||||||
|
|
||||||
handleResponse(translation, detected_lang);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (err_msg.empty())
|
|
||||||
{
|
|
||||||
err_msg = LLTrans::getString("TranslationResponseParseError");
|
|
||||||
}
|
|
||||||
|
|
||||||
llwarns << "Translation request failed: " << err_msg << llendl;
|
|
||||||
handleFailure(status, err_msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LLTranslate::KeyVerificationReceiver::KeyVerificationReceiver(EService service)
|
|
||||||
: mService(service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LLTranslate::EService LLTranslate::KeyVerificationReceiver::getService() const
|
|
||||||
{
|
|
||||||
return mService;
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual
|
|
||||||
void LLTranslate::KeyVerificationReceiver::completedRaw(
|
|
||||||
U32 http_status,
|
|
||||||
const std::string& reason,
|
|
||||||
const LLChannelDescriptors& channels,
|
|
||||||
const LLIOPipe::buffer_ptr_t& buffer)
|
|
||||||
{
|
|
||||||
bool ok = (http_status == 200);
|
|
||||||
setVerificationStatus(ok);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void LLTranslate::translateMessage(
|
void LLTranslate::getTranslateUrl(std::string &translateUrl, const std::string &fromLang, const std::string &toLang, const std::string &mesg)
|
||||||
TranslationReceiverPtr &receiver,
|
|
||||||
const std::string &from_lang,
|
|
||||||
const std::string &to_lang,
|
|
||||||
const std::string &mesg)
|
|
||||||
{
|
{
|
||||||
std::string url;
|
std::string escaped_mesg = LLWeb::curlEscape(mesg);
|
||||||
receiver->mHandler.getTranslateURL(url, from_lang, to_lang, mesg);
|
|
||||||
|
|
||||||
LL_DEBUGS("Translate") << "Sending translation request: " << url << LL_ENDL;
|
translateUrl = m_GoogleURL
|
||||||
sendRequest(url, receiver);
|
+ escaped_mesg + m_GoogleLangSpec
|
||||||
|
+ fromLang // 'from' language; empty string for auto
|
||||||
|
+ "%7C" // |
|
||||||
|
+ toLang; // 'to' language
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
//static
|
||||||
void LLTranslate::verifyKey(
|
void LLTranslate::stringReplaceAll(std::string& context, const std::string& from, const std::string& to)
|
||||||
KeyVerificationReceiverPtr& receiver,
|
|
||||||
const std::string& key)
|
|
||||||
{
|
{
|
||||||
std::string url;
|
size_t lookHere = 0;
|
||||||
const LLTranslationAPIHandler& handler = getHandler(receiver->getService());
|
size_t foundHere;
|
||||||
handler.getKeyVerificationURL(url, key);
|
|
||||||
|
|
||||||
LL_DEBUGS("Translate") << "Sending key verification request: " << url << LL_ENDL;
|
while((foundHere = context.find(from, lookHere))
|
||||||
sendRequest(url, receiver);
|
!= std::string::npos) {
|
||||||
|
context.replace(foundHere, from.size(), to);
|
||||||
|
lookHere = foundHere + to.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//static
|
||||||
|
BOOL LLTranslate::parseGoogleTranslate(const std::string result, std::string &translation, std::string &detectedLanguage)
|
||||||
|
{
|
||||||
|
Json::Value root;
|
||||||
|
Json::Reader reader;
|
||||||
|
BOOL parsingSuccessful = reader.parse(result, root );
|
||||||
|
if ( !parsingSuccessful )
|
||||||
|
{
|
||||||
|
LL_WARNS("JSON") << reader.getFormatedErrorMessages() << LL_ENDL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
translation = root[m_GoogleData].get(m_GoogleTranslation, "").asString();
|
||||||
|
detectedLanguage = root[m_GoogleData].get(m_GoogleLanguage, "").asString();
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
std::string LLTranslate::getTranslateLanguage()
|
std::string LLTranslate::getTranslateLanguage()
|
||||||
{
|
{
|
||||||
std::string language = gSavedSettings.getString("TranslateLanguage");
|
std::string language = "en";
|
||||||
if (language.empty() || language == "default")
|
if (LLUI::sConfigGroup)
|
||||||
{
|
{
|
||||||
language = LLUI::getLanguage();
|
language = LLUI::sConfigGroup->getString("TranslateLanguage");
|
||||||
|
if (language.empty() || language == "default")
|
||||||
|
{
|
||||||
|
language = LLUI::getLanguage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
language = language.substr(0,2);
|
language = language.substr(0,2);
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
bool LLTranslate::isTranslationConfigured()
|
|
||||||
{
|
|
||||||
return getPreferredHandler().isConfigured();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
const LLTranslationAPIHandler& LLTranslate::getPreferredHandler()
|
|
||||||
{
|
|
||||||
EService service = SERVICE_BING;
|
|
||||||
|
|
||||||
std::string service_str = gSavedSettings.getString("TranslationService");
|
|
||||||
if (service_str == "google")
|
|
||||||
{
|
|
||||||
service = SERVICE_GOOGLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getHandler(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
const LLTranslationAPIHandler& LLTranslate::getHandler(EService service)
|
|
||||||
{
|
|
||||||
static LLGoogleTranslationHandler google;
|
|
||||||
static LLBingTranslationHandler bing;
|
|
||||||
|
|
||||||
if (service == SERVICE_GOOGLE)
|
|
||||||
{
|
|
||||||
return google;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void LLTranslate::sendRequest(const std::string& url, LLHTTPClient::ResponderPtr responder)
|
|
||||||
{
|
|
||||||
static const float REQUEST_TIMEOUT = 5;
|
|
||||||
static LLSD sHeader;
|
|
||||||
|
|
||||||
if (!sHeader.size())
|
|
||||||
{
|
|
||||||
std::string user_agent = llformat("%s %d.%d.%d (%d)",
|
|
||||||
gVersionChannel,
|
|
||||||
gVersionMajor,
|
|
||||||
gVersionMinor,
|
|
||||||
gVersionPatch,
|
|
||||||
gVersionBuild);
|
|
||||||
|
|
||||||
sHeader.insert("Accept", "text/plain");
|
|
||||||
sHeader.insert("User-Agent", user_agent);
|
|
||||||
}
|
|
||||||
|
|
||||||
LLHTTPClient::get(url, responder, sHeader, REQUEST_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,27 +2,33 @@
|
|||||||
* @file lltranslate.h
|
* @file lltranslate.h
|
||||||
* @brief Human language translation class and JSON response receiver.
|
* @brief Human language translation class and JSON response receiver.
|
||||||
*
|
*
|
||||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
* $LicenseInfo:firstyear=2009&license=viewergpl$
|
||||||
* Second Life Viewer Source Code
|
*
|
||||||
* Copyright (C) 2010, Linden Research, Inc.
|
* Copyright (c) 2009, Linden Research, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* Second Life Viewer Source Code
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||||
* License as published by the Free Software Foundation;
|
* to you under the terms of the GNU General Public License, version 2.0
|
||||||
* version 2.1 of the License only.
|
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||||
*
|
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||||
* This library is distributed in the hope that it will be useful,
|
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
*
|
||||||
* Lesser General Public License for more details.
|
* There are special exceptions to the terms and conditions of the GPL as
|
||||||
*
|
* it is applied to this Source Code. View the full text of the exception
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||||
* License along with this library; if not, write to the Free Software
|
* online at
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||||
*
|
*
|
||||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
* By copying, modifying or distributing this software, you acknowledge
|
||||||
* $/LicenseInfo$
|
* that you have read and understood your obligations described above,
|
||||||
*/
|
* and agree to abide by those obligations.
|
||||||
|
*
|
||||||
|
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||||
|
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||||
|
* COMPLETENESS OR PERFORMANCE.
|
||||||
|
* $/LicenseInfo$
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef LL_LLTRANSLATE_H
|
#ifndef LL_LLTRANSLATE_H
|
||||||
#define LL_LLTRANSLATE_H
|
#define LL_LLTRANSLATE_H
|
||||||
@@ -31,273 +37,89 @@
|
|||||||
#include "llbufferstream.h"
|
#include "llbufferstream.h"
|
||||||
#include "jsoncpp/reader.h"
|
#include "jsoncpp/reader.h"
|
||||||
|
|
||||||
namespace Json
|
|
||||||
{
|
|
||||||
class Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler of an HTTP machine translation service.
|
|
||||||
*
|
|
||||||
* Derived classes know the service URL
|
|
||||||
* and how to parse the translation result.
|
|
||||||
*/
|
|
||||||
class LLTranslationAPIHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Get URL for translation of the given string.
|
|
||||||
*
|
|
||||||
* Sending HTTP GET request to the URL will initiate translation.
|
|
||||||
*
|
|
||||||
* @param[out] url Place holder for the result.
|
|
||||||
* @param from_lang Source language. Leave empty for auto-detection.
|
|
||||||
* @param to_lang Target language.
|
|
||||||
* @param text Text to translate.
|
|
||||||
*/
|
|
||||||
virtual void getTranslateURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &from_lang,
|
|
||||||
const std::string &to_lang,
|
|
||||||
const std::string &text) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get URL to verify the given API key.
|
|
||||||
*
|
|
||||||
* Sending request to the URL verifies the key.
|
|
||||||
* Positive HTTP response (code 200) means that the key is valid.
|
|
||||||
*
|
|
||||||
* @param[out] url Place holder for the URL.
|
|
||||||
* @param[in] key Key to verify.
|
|
||||||
*/
|
|
||||||
virtual void getKeyVerificationURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &key) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse translation response.
|
|
||||||
*
|
|
||||||
* @param[in,out] status HTTP status. May be modified while parsing.
|
|
||||||
* @param body Response text.
|
|
||||||
* @param[out] translation Translated text.
|
|
||||||
* @param[out] detected_lang Detected source language. May be empty.
|
|
||||||
* @param[out] err_msg Error message (in case of error).
|
|
||||||
*/
|
|
||||||
virtual bool parseResponse(
|
|
||||||
int& status,
|
|
||||||
const std::string& body,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang,
|
|
||||||
std::string& err_msg) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if the handler is configured to function properly
|
|
||||||
*/
|
|
||||||
virtual bool isConfigured() const = 0;
|
|
||||||
|
|
||||||
virtual ~LLTranslationAPIHandler() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static const int STATUS_OK = 200;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Google Translate v2 API handler.
|
|
||||||
class LLGoogleTranslationHandler : public LLTranslationAPIHandler
|
|
||||||
{
|
|
||||||
LOG_CLASS(LLGoogleTranslationHandler);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/*virtual*/ void getTranslateURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &from_lang,
|
|
||||||
const std::string &to_lang,
|
|
||||||
const std::string &text) const;
|
|
||||||
/*virtual*/ void getKeyVerificationURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &key) const;
|
|
||||||
/*virtual*/ bool parseResponse(
|
|
||||||
int& status,
|
|
||||||
const std::string& body,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang,
|
|
||||||
std::string& err_msg) const;
|
|
||||||
/*virtual*/ bool isConfigured() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void parseErrorResponse(
|
|
||||||
const Json::Value& root,
|
|
||||||
int& status,
|
|
||||||
std::string& err_msg);
|
|
||||||
static bool parseTranslation(
|
|
||||||
const Json::Value& root,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang);
|
|
||||||
static std::string getAPIKey();
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Microsoft Translator v2 API handler.
|
|
||||||
class LLBingTranslationHandler : public LLTranslationAPIHandler
|
|
||||||
{
|
|
||||||
LOG_CLASS(LLBingTranslationHandler);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/*virtual*/ void getTranslateURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &from_lang,
|
|
||||||
const std::string &to_lang,
|
|
||||||
const std::string &text) const;
|
|
||||||
/*virtual*/ void getKeyVerificationURL(
|
|
||||||
std::string &url,
|
|
||||||
const std::string &key) const;
|
|
||||||
/*virtual*/ bool parseResponse(
|
|
||||||
int& status,
|
|
||||||
const std::string& body,
|
|
||||||
std::string& translation,
|
|
||||||
std::string& detected_lang,
|
|
||||||
std::string& err_msg) const;
|
|
||||||
/*virtual*/ bool isConfigured() const;
|
|
||||||
private:
|
|
||||||
static std::string getAPIKey();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point for machine translation services.
|
|
||||||
*
|
|
||||||
* Basically, to translate a string, we need to know the URL
|
|
||||||
* of a translation service, have a valid API for the service
|
|
||||||
* and be given the target language.
|
|
||||||
*
|
|
||||||
* Callers specify the string to translate and the target language,
|
|
||||||
* LLTranslate takes care of the rest.
|
|
||||||
*
|
|
||||||
* API keys for translation are taken from saved settings.
|
|
||||||
*/
|
|
||||||
class LLTranslate
|
class LLTranslate
|
||||||
{
|
{
|
||||||
LOG_CLASS(LLTranslate);
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
typedef enum e_service {
|
|
||||||
SERVICE_BING,
|
|
||||||
SERVICE_GOOGLE,
|
|
||||||
} EService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclasses are supposed to handle translation results (e.g. show them in chat)
|
|
||||||
*/
|
|
||||||
class TranslationReceiver: public LLHTTPClient::Responder
|
class TranslationReceiver: public LLHTTPClient::Responder
|
||||||
{
|
{
|
||||||
public:
|
protected:
|
||||||
|
TranslationReceiver(const std::string &fromLang, const std::string &toLang)
|
||||||
|
: m_fromLang(fromLang),
|
||||||
|
m_toLang(toLang)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
virtual void handleResponse(const std::string &translation, const std::string &recognizedLang) {}
|
||||||
* Using mHandler, parse incoming response.
|
virtual void handleFailure() {};
|
||||||
*
|
|
||||||
* Calls either handleResponse() or handleFailure()
|
public:
|
||||||
* depending on the HTTP status code and parsing success.
|
~TranslationReceiver()
|
||||||
*
|
{
|
||||||
* @see handleResponse()
|
}
|
||||||
* @see handleFailure()
|
|
||||||
* @see mHandler
|
virtual void error(U32 status, const std::string& reason)
|
||||||
*/
|
{
|
||||||
/*virtual*/ void completedRaw(
|
LL_WARNS("Translate") << "URL Request error: " << reason << LL_ENDL;
|
||||||
U32 http_status,
|
handleFailure();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void completedRaw(
|
||||||
|
U32 status,
|
||||||
const std::string& reason,
|
const std::string& reason,
|
||||||
const LLChannelDescriptors& channels,
|
const LLChannelDescriptors& channels,
|
||||||
const LLIOPipe::buffer_ptr_t& buffer);
|
const LLIOPipe::buffer_ptr_t& buffer)
|
||||||
|
{
|
||||||
|
LLBufferStream istr(channels, buffer.get());
|
||||||
|
|
||||||
|
std::stringstream strstrm;
|
||||||
|
strstrm << istr.rdbuf();
|
||||||
|
const std::string result = strstrm.str();
|
||||||
|
|
||||||
|
std::string translation;
|
||||||
|
std::string detectedLanguage;
|
||||||
|
|
||||||
|
if (!parseGoogleTranslate(result, translation, detectedLanguage))
|
||||||
|
{
|
||||||
|
handleFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix up the response
|
||||||
|
stringReplaceAll( translation, "<","<");
|
||||||
|
stringReplaceAll( translation, ">",">");
|
||||||
|
stringReplaceAll( translation, ""","\"");
|
||||||
|
stringReplaceAll( translation, "'","'");
|
||||||
|
stringReplaceAll( translation, "&","&");
|
||||||
|
stringReplaceAll( translation, "'","'");
|
||||||
|
|
||||||
|
handleResponse(translation, detectedLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class LLTranslate;
|
const std::string m_toLang;
|
||||||
|
const std::string m_fromLang;
|
||||||
/// Remember source and target languages for subclasses to be able to filter inappropriate results.
|
|
||||||
TranslationReceiver(const std::string& from_lang, const std::string& to_lang);
|
|
||||||
|
|
||||||
/// Override point to handle successful translation.
|
|
||||||
virtual void handleResponse(const std::string &translation, const std::string &recognized_lang) = 0;
|
|
||||||
|
|
||||||
/// Override point to handle unsuccessful translation.
|
|
||||||
virtual void handleFailure(int status, const std::string& err_msg) = 0;
|
|
||||||
|
|
||||||
std::string mFromLang;
|
|
||||||
std::string mToLang;
|
|
||||||
const LLTranslationAPIHandler& mHandler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
static void translateMessage(LLHTTPClient::ResponderPtr &result, const std::string &fromLang, const std::string &toLang, const std::string &mesg);
|
||||||
* Subclasses are supposed to handle API key verification result.
|
static float m_GoogleTimeout;
|
||||||
*/
|
|
||||||
class KeyVerificationReceiver: public LLHTTPClient::Responder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
EService getService() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Save the translation service the key belongs to.
|
|
||||||
*
|
|
||||||
* Subclasses need to know it.
|
|
||||||
*
|
|
||||||
* @see getService()
|
|
||||||
*/
|
|
||||||
KeyVerificationReceiver(EService service);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse verification response.
|
|
||||||
*
|
|
||||||
* Calls setVerificationStatus() with the verification status,
|
|
||||||
* which is true if HTTP status code is 200.
|
|
||||||
*
|
|
||||||
* @see setVerificationStatus()
|
|
||||||
*/
|
|
||||||
/*virtual*/ void completedRaw(
|
|
||||||
U32 http_status,
|
|
||||||
const std::string& reason,
|
|
||||||
const LLChannelDescriptors& channels,
|
|
||||||
const LLIOPipe::buffer_ptr_t& buffer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override point for subclasses to handle key verification status.
|
|
||||||
*/
|
|
||||||
virtual void setVerificationStatus(bool ok) = 0;
|
|
||||||
|
|
||||||
EService mService;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef boost::intrusive_ptr<TranslationReceiver> TranslationReceiverPtr;
|
|
||||||
typedef boost::intrusive_ptr<KeyVerificationReceiver> KeyVerificationReceiverPtr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translate given text.
|
|
||||||
*
|
|
||||||
* @param receiver Object to pass translation result to.
|
|
||||||
* @param from_lang Source language. Leave empty for auto-detection.
|
|
||||||
* @param to_lang Target language.
|
|
||||||
* @param mesg Text to translate.
|
|
||||||
*/
|
|
||||||
static void translateMessage(TranslationReceiverPtr &receiver, const std::string &from_lang, const std::string &to_lang, const std::string &mesg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify given API key of a translation service.
|
|
||||||
*
|
|
||||||
* @param receiver Object to pass verification result to.
|
|
||||||
* @param key Key to verify.
|
|
||||||
*/
|
|
||||||
static void verifyKey(KeyVerificationReceiverPtr& receiver, const std::string& key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return translation target language
|
|
||||||
*/
|
|
||||||
static std::string getTranslateLanguage();
|
static std::string getTranslateLanguage();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if translation is configured properly.
|
|
||||||
*/
|
|
||||||
static bool isTranslationConfigured();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const LLTranslationAPIHandler& getPreferredHandler();
|
static void getTranslateUrl(std::string &translateUrl, const std::string &fromLang, const std::string &toLang, const std::string &text);
|
||||||
static const LLTranslationAPIHandler& getHandler(EService service);
|
static void stringReplaceAll(std::string& context, const std::string& from, const std::string& to);
|
||||||
static void sendRequest(const std::string& url, LLHTTPClient::ResponderPtr responder);
|
static BOOL parseGoogleTranslate(const std::string result, std::string &translation, std::string &detectedLanguage);
|
||||||
|
|
||||||
|
static LLSD m_Header;
|
||||||
|
static const char* m_GoogleURL;
|
||||||
|
static const char* m_GoogleLangSpec;
|
||||||
|
static const char* m_AcceptHeader;
|
||||||
|
static const char* m_AcceptType;
|
||||||
|
static const char* m_AgentHeader;
|
||||||
|
static const char* m_UserAgent;
|
||||||
|
|
||||||
|
static const char* m_GoogleData;
|
||||||
|
static const char* m_GoogleTranslation;
|
||||||
|
static const char* m_GoogleLanguage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2957,23 +2957,23 @@ void process_decline_callingcard(LLMessageSystem* msg, void**)
|
|||||||
class ChatTranslationReceiver : public LLTranslate::TranslationReceiver
|
class ChatTranslationReceiver : public LLTranslate::TranslationReceiver
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ChatTranslationReceiver(const std::string &from_lang, const std::string &to_lang, LLChat *chat,
|
ChatTranslationReceiver(const std::string &fromLang, const std::string &toLang, LLChat *chat,
|
||||||
const BOOL history)
|
const BOOL history)
|
||||||
: LLTranslate::TranslationReceiver(from_lang, to_lang),
|
: LLTranslate::TranslationReceiver(fromLang, toLang),
|
||||||
m_chat(chat),
|
m_chat(chat),
|
||||||
m_history(history)
|
m_history(history)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &from_lang, const std::string &to_lang, LLChat *chat, const BOOL history)
|
static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &fromLang, const std::string &toLang, LLChat *chat, const BOOL history)
|
||||||
{
|
{
|
||||||
return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(from_lang, to_lang, chat, history));
|
return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(fromLang, toLang, chat, history));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void handleResponse(const std::string &translation, const std::string &detectedLanguage)
|
void handleResponse(const std::string &translation, const std::string &detectedLanguage)
|
||||||
{
|
{
|
||||||
if (mToLang != detectedLanguage)
|
if (m_toLang != detectedLanguage)
|
||||||
m_chat->mText += " (" + translation + ")";
|
m_chat->mText += " (" + translation + ")";
|
||||||
|
|
||||||
add_floater_chat(*m_chat, m_history);
|
add_floater_chat(*m_chat, m_history);
|
||||||
@@ -2981,12 +2981,14 @@ protected:
|
|||||||
delete m_chat;
|
delete m_chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFailure(int status, const std::string& err_msg)
|
void handleFailure()
|
||||||
{
|
{
|
||||||
llwarns << "Translation failed for mesg " << m_chat << " toLang " << mToLang << " fromLang " << mFromLang << llendl;
|
LLTranslate::TranslationReceiver::handleFailure();
|
||||||
|
|
||||||
m_chat->mText += " (?)";
|
m_chat->mText += " (?)";
|
||||||
|
|
||||||
add_floater_chat(*m_chat, m_history);
|
add_floater_chat(*m_chat, m_history);
|
||||||
|
|
||||||
delete m_chat;
|
delete m_chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3015,12 +3017,14 @@ void check_translate_chat(const std::string &mesg, LLChat &chat, const BOOL hist
|
|||||||
|
|
||||||
if (translate && chat.mSourceType != CHAT_SOURCE_SYSTEM)
|
if (translate && chat.mSourceType != CHAT_SOURCE_SYSTEM)
|
||||||
{
|
{
|
||||||
const std::string &from_lang = "";
|
// fromLang hardcoded to "" (autodetection) pending implementation of
|
||||||
const std::string &to_lang = LLTranslate::getTranslateLanguage();
|
// SVC-4879
|
||||||
|
const std::string &fromLang = "";
|
||||||
|
const std::string &toLang = LLTranslate::getTranslateLanguage();
|
||||||
LLChat *newChat = new LLChat(chat);
|
LLChat *newChat = new LLChat(chat);
|
||||||
|
|
||||||
LLTranslate::TranslationReceiverPtr result = ChatTranslationReceiver::build(from_lang, to_lang, newChat, history);
|
LLHTTPClient::ResponderPtr result = ChatTranslationReceiver::build(fromLang, toLang, newChat, history);
|
||||||
LLTranslate::translateMessage(result, from_lang, to_lang, mesg);
|
LLTranslate::translateMessage(result, fromLang, toLang, mesg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user