summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2011-09-07 16:14:47 +0300
committerVadim ProductEngine <vsavchuk@productengine.com>2011-09-07 16:14:47 +0300
commit7975ab138b6ac54fc831613e4d3dfb913c5efbd2 (patch)
tree920aa0b613f59bf933c6bdf409a95147f3bbbb89 /indra
parente23ecf311c729be7e6611ef2fe21badaf9f1c3ed (diff)
STORM-1577 Removed support for Google Translate v1 API.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/settings.xml10
-rw-r--r--indra/newview/llfloatertranslationsettings.cpp8
-rw-r--r--indra/newview/lltranslate.cpp67
-rw-r--r--indra/newview/skins/default/xui/en/floater_translation_settings.xml4
4 files changed, 18 insertions, 71 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 2549538df2..2f1a2093b2 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10925,18 +10925,18 @@
<key>TranslationService</key>
<map>
<key>Comment</key>
- <string>Translation API to use. (google_v1|google_v2|bing)</string>
+ <string>Translation API to use. (google|bing)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
- <string>google_v1</string>
+ <string>bing</string>
</map>
- <key>GoogleTranslateAPIv2Key</key>
+ <key>GoogleTranslateAPIKey</key>
<map>
<key>Comment</key>
- <string>Google Translate API v2 key</string>
+ <string>Google Translate API key</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -10947,7 +10947,7 @@
<key>BingTranslateAPIKey</key>
<map>
<key>Comment</key>
- <string>Bing AppID to use with the Microsoft Translator V2 API</string>
+ <string>Bing AppID to use with the Microsoft Translator API</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
diff --git a/indra/newview/llfloatertranslationsettings.cpp b/indra/newview/llfloatertranslationsettings.cpp
index 56f101d149..107205aed3 100644
--- a/indra/newview/llfloatertranslationsettings.cpp
+++ b/indra/newview/llfloatertranslationsettings.cpp
@@ -75,7 +75,7 @@ void LLFloaterTranslationSettings::onOpen(const LLSD& key)
mLanguageCombo->setSelectedByValue(gSavedSettings.getString("TranslateLanguage"), TRUE);
mTranslationServiceRadioGroup->setSelectedByValue(gSavedSettings.getString("TranslationService"), TRUE);
mBingAPIKeyEditor->setText(gSavedSettings.getString("BingTranslateAPIKey"));
- mGoogleAPIKeyEditor->setText(gSavedSettings.getString("GoogleTranslateAPIv2Key"));
+ mGoogleAPIKeyEditor->setText(gSavedSettings.getString("GoogleTranslateAPIKey"));
updateControlsEnabledState();
}
@@ -104,7 +104,7 @@ bool LLFloaterTranslationSettings::validate()
return false;
}
- if (service == "google_v2" && mGoogleAPIKeyEditor->getText().empty())
+ if (service == "google" && mGoogleAPIKeyEditor->getText().empty())
{
showError("no_google_api_key");
return false;
@@ -129,7 +129,7 @@ void LLFloaterTranslationSettings::updateControlsEnabledState()
mGoogleAPIKeyEditor->setEnabled(on);
mBingAPIKeyEditor->setEnabled(service == "bing");
- mGoogleAPIKeyEditor->setEnabled(service == "google_v2");
+ mGoogleAPIKeyEditor->setEnabled(service == "google");
}
void LLFloaterTranslationSettings::onBtnOK()
@@ -140,7 +140,7 @@ void LLFloaterTranslationSettings::onBtnOK()
gSavedSettings.setString("TranslateLanguage", mLanguageCombo->getSelectedValue().asString());
gSavedSettings.setString("TranslationService", getSelectedService());
gSavedSettings.setString("BingTranslateAPIKey", mBingAPIKeyEditor->getText());
- gSavedSettings.setString("GoogleTranslateAPIv2Key", mGoogleAPIKeyEditor->getText());
+ gSavedSettings.setString("GoogleTranslateAPIKey", mGoogleAPIKeyEditor->getText());
closeFloater(false);
}
}
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;
diff --git a/indra/newview/skins/default/xui/en/floater_translation_settings.xml b/indra/newview/skins/default/xui/en/floater_translation_settings.xml
index 40a176830c..f21f64fcf6 100644
--- a/indra/newview/skins/default/xui/en/floater_translation_settings.xml
+++ b/indra/newview/skins/default/xui/en/floater_translation_settings.xml
@@ -137,10 +137,10 @@
layout="topleft"
name="bing" />
<radio_item
- initial_value="google_v2"
+ initial_value="google"
label="Google Translate"
layout="topleft"
- name="google_v2"
+ name="google"
top_pad="20" />
</radio_group>