summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/CMakeLists.txt2
-rwxr-xr-xindra/newview/llfloaterpreference.cpp9
-rw-r--r--indra/newview/llfloaterpreference.h1
-rw-r--r--indra/newview/llfloatertranslationsettings.cpp146
-rw-r--r--indra/newview/llfloatertranslationsettings.h59
-rw-r--r--indra/newview/llviewerfloaterreg.cpp2
-rw-r--r--indra/newview/skins/default/xui/en/floater_translation_settings.xml222
-rw-r--r--indra/newview/skins/default/xui/en/panel_preferences_chat.xml12
8 files changed, 453 insertions, 0 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index a117d9a593..e7ca2a4294 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -237,6 +237,7 @@ set(viewer_SOURCE_FILES
llfloatertools.cpp
llfloatertopobjects.cpp
llfloatertos.cpp
+ llfloatertranslationsettings.cpp
llfloateruipreview.cpp
llfloaterurlentry.cpp
llfloatervoiceeffect.cpp
@@ -799,6 +800,7 @@ set(viewer_HEADER_FILES
llfloatertools.h
llfloatertopobjects.h
llfloatertos.h
+ llfloatertranslationsettings.h
llfloateruipreview.h
llfloaterurlentry.h
llfloatervoiceeffect.h
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index d65928e385..07c07d608a 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -345,6 +345,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this));
mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this));
mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this));
+ mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
sSkin = gSavedSettings.getString("SkinCurrent");
@@ -602,6 +603,9 @@ void LLFloaterPreference::cancel()
}
// hide joystick pref floater
LLFloaterReg::hideInstance("pref_joystick");
+
+ // hide translation settings floater
+ LLFloaterReg::hideInstance("prefs_translation");
// cancel hardware menu
LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
@@ -1553,6 +1557,11 @@ void LLFloaterPreference::onClickProxySettings()
LLFloaterReg::showInstance("prefs_proxy");
}
+void LLFloaterPreference::onClickTranslationSettings()
+{
+ LLFloaterReg::showInstance("prefs_translation");
+}
+
void LLFloaterPreference::updateDoubleClickControls()
{
// check is one of double-click actions settings enabled
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index ef9bc2dd53..ee6bb235be 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -157,6 +157,7 @@ public:
void onChangeMaturity();
void onClickBlockList();
void onClickProxySettings();
+ void onClickTranslationSettings();
void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
void getUIColor(LLUICtrl* ctrl, const LLSD& param);
diff --git a/indra/newview/llfloatertranslationsettings.cpp b/indra/newview/llfloatertranslationsettings.cpp
new file mode 100644
index 0000000000..56f101d149
--- /dev/null
+++ b/indra/newview/llfloatertranslationsettings.cpp
@@ -0,0 +1,146 @@
+/**
+ * @file llfloatertranslationsettings.cpp
+ * @brief Machine translation settings for chat
+ *
+ * $LicenseInfo:firstyear=2011&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llfloatertranslationsettings.h"
+
+// Viewer includes
+#include "llviewercontrol.h" // for gSavedSettings
+
+// Linden library includes
+#include "llbutton.h"
+#include "llcheckboxctrl.h"
+#include "llcombobox.h"
+#include "llfloaterreg.h"
+#include "lllineeditor.h"
+#include "llnotificationsutil.h"
+#include "llradiogroup.h"
+
+LLFloaterTranslationSettings::LLFloaterTranslationSettings(const LLSD& key)
+: LLFloater(key)
+, mMachineTranslationCB(NULL)
+, mLanguageCombo(NULL)
+, mTranslationServiceRadioGroup(NULL)
+, mBingAPIKeyEditor(NULL)
+, mGoogleAPIKeyEditor(NULL)
+{
+}
+
+// virtual
+BOOL LLFloaterTranslationSettings::postBuild()
+{
+ mMachineTranslationCB = getChild<LLCheckBoxCtrl>("translate_chat_checkbox");
+ mLanguageCombo = getChild<LLComboBox>("translate_language_combo");
+ mTranslationServiceRadioGroup = getChild<LLRadioGroup>("translation_service_rg");
+ mBingAPIKeyEditor = getChild<LLLineEditor>("bing_api_key");
+ mGoogleAPIKeyEditor = getChild<LLLineEditor>("google_api_key");
+
+ mMachineTranslationCB->setCommitCallback(boost::bind(&LLFloaterTranslationSettings::updateControlsEnabledState, this));
+ mTranslationServiceRadioGroup->setCommitCallback(boost::bind(&LLFloaterTranslationSettings::updateControlsEnabledState, this));
+ getChild<LLButton>("ok_btn")->setClickedCallback(boost::bind(&LLFloaterTranslationSettings::onBtnOK, this));
+ getChild<LLButton>("cancel_btn")->setClickedCallback(boost::bind(&LLFloater::closeFloater, this, false));
+
+ center();
+ return TRUE;
+}
+
+// virtual
+void LLFloaterTranslationSettings::onOpen(const LLSD& key)
+{
+ mMachineTranslationCB->setValue(gSavedSettings.getBOOL("TranslateChat"));
+ mLanguageCombo->setSelectedByValue(gSavedSettings.getString("TranslateLanguage"), TRUE);
+ mTranslationServiceRadioGroup->setSelectedByValue(gSavedSettings.getString("TranslationService"), TRUE);
+ mBingAPIKeyEditor->setText(gSavedSettings.getString("BingTranslateAPIKey"));
+ mGoogleAPIKeyEditor->setText(gSavedSettings.getString("GoogleTranslateAPIv2Key"));
+
+ updateControlsEnabledState();
+}
+
+std::string LLFloaterTranslationSettings::getSelectedService() const
+{
+ return mTranslationServiceRadioGroup->getSelectedValue().asString();
+}
+
+void LLFloaterTranslationSettings::showError(const std::string& err_name)
+{
+ LLSD args;
+ args["MESSAGE"] = getString(err_name);
+ LLNotificationsUtil::add("GenericAlert", args);
+}
+
+bool LLFloaterTranslationSettings::validate()
+{
+ bool translate_chat = mMachineTranslationCB->getValue().asBoolean();
+ if (!translate_chat) return true;
+
+ std::string service = getSelectedService();
+ if (service == "bing" && mBingAPIKeyEditor->getText().empty())
+ {
+ showError("no_bing_api_key");
+ return false;
+ }
+
+ if (service == "google_v2" && mGoogleAPIKeyEditor->getText().empty())
+ {
+ showError("no_google_api_key");
+ return false;
+ }
+
+ return true;
+}
+
+void LLFloaterTranslationSettings::updateControlsEnabledState()
+{
+ // Enable/disable controls based on the checkbox value.
+ bool on = mMachineTranslationCB->getValue().asBoolean();
+ std::string service = getSelectedService();
+
+ mTranslationServiceRadioGroup->setEnabled(on);
+ mLanguageCombo->setEnabled(on);
+
+ getChild<LLTextBox>("bing_api_key_label")->setEnabled(on);
+ mBingAPIKeyEditor->setEnabled(on);
+
+ getChild<LLTextBox>("google_api_key_label")->setEnabled(on);
+ mGoogleAPIKeyEditor->setEnabled(on);
+
+ mBingAPIKeyEditor->setEnabled(service == "bing");
+ mGoogleAPIKeyEditor->setEnabled(service == "google_v2");
+}
+
+void LLFloaterTranslationSettings::onBtnOK()
+{
+ if (validate())
+ {
+ gSavedSettings.setBOOL("TranslateChat", mMachineTranslationCB->getValue().asBoolean());
+ gSavedSettings.setString("TranslateLanguage", mLanguageCombo->getSelectedValue().asString());
+ gSavedSettings.setString("TranslationService", getSelectedService());
+ gSavedSettings.setString("BingTranslateAPIKey", mBingAPIKeyEditor->getText());
+ gSavedSettings.setString("GoogleTranslateAPIv2Key", mGoogleAPIKeyEditor->getText());
+ closeFloater(false);
+ }
+}
diff --git a/indra/newview/llfloatertranslationsettings.h b/indra/newview/llfloatertranslationsettings.h
new file mode 100644
index 0000000000..1c03b86f4d
--- /dev/null
+++ b/indra/newview/llfloatertranslationsettings.h
@@ -0,0 +1,59 @@
+/**
+ * @file llfloatertranslationsettings.h
+ * @brief Machine translation settings for chat
+ *
+ * $LicenseInfo:firstyear=2011&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLFLOATERTRANSLATIONSETTINGS_H
+#define LL_LLFLOATERTRANSLATIONSETTINGS_H
+
+#include "llfloater.h"
+
+class LLCheckBoxCtrl;
+class LLComboBox;
+class LLLineEditor;
+class LLRadioGroup;
+
+class LLFloaterTranslationSettings : public LLFloater
+{
+public:
+ LLFloaterTranslationSettings(const LLSD& key);
+ /*virtual*/ BOOL postBuild();
+ /*virtual*/ void onOpen(const LLSD& key);
+
+private:
+ std::string getSelectedService() const;
+ void showError(const std::string& err_name);
+ bool validate();
+ void updateControlsEnabledState();
+ void onMachineTranslationToggle();
+ void onBtnOK();
+
+ LLCheckBoxCtrl* mMachineTranslationCB;
+ LLComboBox* mLanguageCombo;
+ LLLineEditor* mBingAPIKeyEditor;
+ LLLineEditor* mGoogleAPIKeyEditor;
+ LLRadioGroup* mTranslationServiceRadioGroup;
+};
+
+#endif // LL_LLFLOATERTRANSLATIONSETTINGS_H
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index fecc6d91bd..3be26d87e2 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -102,6 +102,7 @@
#include "llfloatertools.h"
#include "llfloatertos.h"
#include "llfloatertopobjects.h"
+#include "llfloatertranslationsettings.h"
#include "llfloateruipreview.h"
#include "llfloatervoiceeffect.h"
#include "llfloaterwhitelistentry.h"
@@ -234,6 +235,7 @@ void LLViewerFloaterReg::registerFloaters()
LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
LLFloaterReg::add("prefs_hardware_settings", "floater_hardware_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHardwareSettings>);
+ LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
LLFloaterReg::add("perm_prefs", "floater_perm_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPerms>);
LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
diff --git a/indra/newview/skins/default/xui/en/floater_translation_settings.xml b/indra/newview/skins/default/xui/en/floater_translation_settings.xml
new file mode 100644
index 0000000000..40a176830c
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_translation_settings.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ legacy_header_height="18"
+ height="320"
+ layout="topleft"
+ name="floater_translation_settings"
+ help_topic="environment_editor_floater"
+ save_rect="true"
+ title="TRANSLATION SETTINGS"
+ width="350">
+
+ <string name="no_bing_api_key">Bing Translator requires and appID to function.</string>
+ <string name="no_google_api_key">Google Translate requires an API key to function.</string>
+
+ <check_box
+ height="16"
+ label="Use machine translation while chatting"
+ layout="topleft"
+ left="10"
+ name="translate_chat_checkbox"
+ top="30"
+ width="20" />
+ <text
+ height="20"
+ follows="left|top"
+ layout="topleft"
+ left="10"
+ name="translate_language_label"
+ top_pad="20"
+ width="130">
+ Translate chat into:
+ </text>
+ <combo_box
+ allow_text_entry="true"
+ follows="left|top"
+ height="23"
+ left_pad="10"
+ max_chars="135"
+ mouse_opaque="true"
+ name="translate_language_combo"
+ top_delta="-5"
+ width="190">
+ <combo_box.item
+ label="System Default"
+ name="System Default Language"
+ value="default" />
+ <combo_box.item
+ label="English"
+ name="English"
+ value="en" />
+ <!-- After "System Default" and "English", please keep the rest of these combo_box.items in alphabetical order by the first character in the string. -->
+ <combo_box.item
+ label="Dansk (Danish)"
+ name="Danish"
+ value="da" />
+ <combo_box.item
+ label="Deutsch (German)"
+ name="German"
+ value="de" />
+ <combo_box.item
+ label="Español (Spanish)"
+ name="Spanish"
+ value="es" />
+ <combo_box.item
+ label="Français (French)"
+ name="French"
+ value="fr" />
+ <combo_box.item
+ label="Italiano (Italian)"
+ name="Italian"
+ value="it" />
+ <combo_box.item
+ label="Magyar (Hungarian)"
+ name="Hungarian"
+ value="hu" />
+ <combo_box.item
+ label="Nederlands (Dutch)"
+ name="Dutch"
+ value="nl" />
+ <combo_box.item
+ label="Polski (Polish)"
+ name="Polish"
+ value="pl" />
+ <combo_box.item
+ label="Português (Portuguese)"
+ name="Portugese"
+ value="pt" />
+ <combo_box.item
+ label="Русский (Russian)"
+ name="Russian"
+ value="ru" />
+ <combo_box.item
+ label="Türkçe (Turkish)"
+ name="Turkish"
+ value="tr" />
+ <combo_box.item
+ label="Українська (Ukrainian)"
+ name="Ukrainian"
+ value="uk" />
+ <combo_box.item
+ label="中文 (简体) (Chinese)"
+ name="Chinese"
+ value="zh" />
+ <combo_box.item
+ label="日本語 (Japanese)"
+ name="Japanese"
+ value="ja" />
+ <combo_box.item
+ label="한국어 (Korean)"
+ name="Korean"
+ value="ko" />
+ </combo_box>
+
+ <text
+ follows="top|left|right"
+ height="15"
+ layout="topleft"
+ left="10"
+ name="tip"
+ top_pad="20"
+ width="330"
+ wrap="true">
+ Choose translation service to use:
+ </text>
+
+ <radio_group
+ follows="top|left"
+ height="55"
+ layout="topleft"
+ left_delta="10"
+ name="translation_service_rg"
+ top_pad="20"
+ width="320">
+ <radio_item
+ initial_value="bing"
+ label="Bing Translator"
+ layout="topleft"
+ name="bing" />
+ <radio_item
+ initial_value="google_v2"
+ label="Google Translate"
+ layout="topleft"
+ name="google_v2"
+ top_pad="20" />
+ </radio_group>
+
+ <text
+ type="string"
+ length="1"
+ follows="top|right"
+ height="20"
+ layout="topleft"
+ left="10"
+ name="bing_api_key_label"
+ top_pad="20"
+ width="100">
+ Bing [http://www.bing.com/developers/createapp.aspx AppID]:
+ </text>
+ <line_editor
+ follows="top|left"
+ height="20"
+ layout="topleft"
+ left_pad="10"
+ max_length_chars="50"
+ top_delta="-4"
+ name="bing_api_key"
+ value=""
+ width="220" />
+
+ <text
+ follows="top|right"
+ height="20"
+ layout="topleft"
+ left="10"
+ length="1"
+ name="google_api_key_label"
+ top_pad="20"
+ type="string"
+ width="100">
+ Google [http://code.google.com/apis/language/translate/v2/pricing.html API key]:
+ </text>
+ <line_editor
+ follows="top|left"
+ height="20"
+ layout="topleft"
+ left_pad="10"
+ max_length_chars="50"
+ top_delta="-4"
+ name="google_api_key"
+ width="220" />
+
+ <text
+ follows="top|right"
+ height="20"
+ layout="topleft"
+ left="155"
+ length="1"
+ name="google_pricing_link"
+ top_delta="-80"
+ type="string"
+ width="100">
+ ([http://code.google.com/apis/language/translate/v2/pricing.html pricing])
+ </text>
+
+ <button
+ follows="left|top"
+ height="23"
+ label="OK"
+ layout="topleft"
+ right="-120"
+ name="ok_btn"
+ top="-30"
+ width="100" />
+ <button
+ follows="left|top"
+ height="23"
+ label="Cancel"
+ layout="topleft"
+ left_pad="10"
+ name="cancel_btn"
+ width="100" />
+</floater>
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
index ea09286592..3fbf484ab2 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
@@ -319,4 +319,16 @@
name="Korean"
value="ko" />
</combo_box>
+ <button
+ follows="left|top"
+ height="23"
+ label="Translation Settings"
+ layout="topleft"
+ right="-50"
+ name="ok_btn"
+ top="-30"
+ width="130">
+ <button.commit_callback
+ function="Pref.TranslationSettings" />
+ </button>
</panel> \ No newline at end of file