diff options
author | niel@nirvana-win7hp.planescape.home <niel@nirvana-win7hp.planescape.home> | 2011-10-26 01:42:26 +0100 |
---|---|---|
committer | niel@nirvana-win7hp.planescape.home <niel@nirvana-win7hp.planescape.home> | 2011-10-26 01:42:26 +0100 |
commit | 4fd9a53115bf85ffe17974323d5fa609e0df960c (patch) | |
tree | 7968008d0fa7c0347d637e1fb19add9d436b926d /indra/newview/lltranslate.cpp | |
parent | 42c166e451d362609d83fb17261f9e8f344e974d (diff) | |
parent | b7a349f231977d5917b29faacca143a85d925576 (diff) |
Merge STORM-959
Diffstat (limited to 'indra/newview/lltranslate.cpp')
-rw-r--r-- | indra/newview/lltranslate.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp index 2f60b6b90b..3692f67a8d 100644 --- a/indra/newview/lltranslate.cpp +++ b/indra/newview/lltranslate.cpp @@ -53,6 +53,45 @@ const char* LLTranslate::m_GoogleData = "responseData"; const char* LLTranslate::m_GoogleTranslation = "translatedText"; const char* LLTranslate::m_GoogleLanguage = "detectedSourceLanguage"; +// virtual +void LLTranslate::TranslationReceiver::completedRaw( U32 status, + const std::string& reason, + const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) +{ + if (200 <= status && status < 300) + { + LLBufferStream istr(channels, buffer.get()); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + + const std::string result = strstrm.str(); + std::string translation; + std::string detected_language; + + if (!parseGoogleTranslate(result, translation, detected_language)) + { + handleFailure(); + return; + } + + // 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_language); + } + else + { + LL_WARNS("Translate") << "HTTP request for Google Translate failed with status " << status << ", reason: " << reason << LL_ENDL; + handleFailure(); + } +} + //static void LLTranslate::translateMessage(LLHTTPClient::ResponderPtr &result, const std::string &from_lang, const std::string &to_lang, const std::string &mesg) { |