summaryrefslogtreecommitdiff
path: root/indra/newview/lltranslate.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-10-21 13:49:35 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-10-21 13:49:35 -0400
commite32227e90b8911200bfd103ff466ddb9231c6619 (patch)
treeab8052cbb14066c95c88f11d621b3239d8154913 /indra/newview/lltranslate.cpp
parent1c58b3b18ea732e0032e70ae6dc9c8ec2f2834b4 (diff)
SH-2557 WIP - some cleanup, added error message to try to isolate causes of translation failure
Diffstat (limited to 'indra/newview/lltranslate.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/lltranslate.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp
index 2f60b6b90b..3692f67a8d 100644..100755
--- 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, "&lt;", "<");
+ LLStringUtil::replaceString(translation, "&gt;",">");
+ LLStringUtil::replaceString(translation, "&quot;","\"");
+ LLStringUtil::replaceString(translation, "&#39;","'");
+ LLStringUtil::replaceString(translation, "&amp;","&");
+ LLStringUtil::replaceString(translation, "&apos;","'");
+
+ 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)
{