diff options
author | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-09-07 16:14:47 +0300 |
---|---|---|
committer | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-09-07 16:14:47 +0300 |
commit | 7975ab138b6ac54fc831613e4d3dfb913c5efbd2 (patch) | |
tree | 920aa0b613f59bf933c6bdf409a95147f3bbbb89 /indra/newview/lltranslate.cpp | |
parent | e23ecf311c729be7e6611ef2fe21badaf9f1c3ed (diff) |
STORM-1577 Removed support for Google Translate v1 API.
Diffstat (limited to 'indra/newview/lltranslate.cpp')
-rw-r--r-- | indra/newview/lltranslate.cpp | 67 |
1 files changed, 7 insertions, 60 deletions
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp index e29ea373ce..6576cbbe64 100644 --- a/indra/newview/lltranslate.cpp +++ b/indra/newview/lltranslate.cpp @@ -59,57 +59,9 @@ protected: static const int STATUS_OK = 200; }; -class LLGoogleV1Handler : public LLTranslationAPIHandler +class LLGoogleHandler : public LLTranslationAPIHandler { - LOG_CLASS(LLGoogleV1Handler); - -public: - /*virtual*/ void getTranslateURL( - std::string &url, - const std::string &from_lang, - const std::string &to_lang, - const std::string &text) const - { - url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" - + LLURI::escape(text) - + "&langpair=" + from_lang + "%7C" + to_lang; - } - - /*virtual*/ bool 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; - } - - // This API doesn't return proper status in the HTTP response header, - // but it is in the body. - status = root["responseStatus"].asInt(); - if (status != STATUS_OK) - { - err_msg = root["responseDetails"].asString(); - return false; - } - - const Json::Value& response_data = root["responseData"]; - translation = response_data.get("translatedText", "").asString(); - detected_lang = response_data.get("detectedSourceLanguage", "").asString(); - return true; - } -}; - -class LLGoogleV2Handler : public LLTranslationAPIHandler -{ - LOG_CLASS(LLGoogleV2Handler); + LOG_CLASS(LLGoogleHandler); public: /*virtual*/ void getTranslateURL( @@ -159,7 +111,7 @@ public: private: static std::string getAPIKey() { - return gSavedSettings.getString("GoogleTranslateAPIv2Key"); + return gSavedSettings.getString("GoogleTranslateAPIKey"); } }; @@ -311,18 +263,13 @@ std::string LLTranslate::getTranslateLanguage() // static const LLTranslationAPIHandler& LLTranslate::getPreferredHandler() { - static LLGoogleV1Handler google_v1; - static LLGoogleV2Handler google_v2; - static LLBingHandler bing; + static LLGoogleHandler google; + static LLBingHandler bing; std::string service = gSavedSettings.getString("TranslationService"); - if (service == "google_v2") - { - return google_v2; - } - else if (service == "google_v1") + if (service == "google") { - return google_v1; + return google; } return bing; |