diff options
author | thickbrick | 2010-09-23 16:56:54 +0200 |
---|---|---|
committer | thickbrick | 2010-09-25 13:28:18 +0200 |
commit | 4a625979b8ccb9ffc0c543cdf5fba37008226504 (patch) | |
tree | 3bef3cc75486e2838815f7546cabe1cea4f37abe | |
parent | Changed version to Experimental 2010.09.18 (diff) | |
download | meta-impy-4a625979b8ccb9ffc0c543cdf5fba37008226504.zip meta-impy-4a625979b8ccb9ffc0c543cdf5fba37008226504.tar.gz meta-impy-4a625979b8ccb9ffc0c543cdf5fba37008226504.tar.bz2 meta-impy-4a625979b8ccb9ffc0c543cdf5fba37008226504.tar.xz |
Make chat translator ignore non-interesting translations (empty or same as
original,) that may result from Google Translate's language autodetec failure.
-rwxr-xr-x | linden/indra/newview/llviewermessage.cpp | 45 | ||||
-rw-r--r-- | linden/indra/newview/llviewermessage.h | 2 |
2 files changed, 25 insertions, 22 deletions
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index bfd1045..1bab3ff 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp | |||
@@ -2716,43 +2716,46 @@ void process_decline_callingcard(LLMessageSystem* msg, void**) | |||
2716 | class ChatTranslationReceiver : public LLTranslate::TranslationReceiver | 2716 | class ChatTranslationReceiver : public LLTranslate::TranslationReceiver |
2717 | { | 2717 | { |
2718 | public : | 2718 | public : |
2719 | ChatTranslationReceiver(const std::string &fromLang, const std::string &toLang, LLChat *chat, | 2719 | ChatTranslationReceiver(const std::string &fromLang, const std::string &toLang, const LLChat &chat, |
2720 | const BOOL history) | 2720 | const std::string &orig_mesg, const BOOL history) |
2721 | : LLTranslate::TranslationReceiver(fromLang, toLang), | 2721 | : LLTranslate::TranslationReceiver(fromLang, toLang), |
2722 | m_chat(chat), | 2722 | m_chat(chat), |
2723 | m_origMesg(orig_mesg), | ||
2723 | m_history(history) | 2724 | m_history(history) |
2724 | { | 2725 | { |
2725 | } | 2726 | } |
2726 | 2727 | ||
2727 | static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &fromLang, const std::string &toLang, LLChat *chat, const BOOL history) | 2728 | static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &fromLang, const std::string &toLang, const LLChat &chat, const std::string &orig_mesg, const BOOL history) |
2728 | { | 2729 | { |
2729 | return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(fromLang, toLang, chat, history)); | 2730 | return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(fromLang, toLang, chat, orig_mesg, history)); |
2730 | } | 2731 | } |
2731 | 2732 | ||
2732 | protected: | 2733 | protected: |
2733 | void handleResponse(const std::string &translation, const std::string &detectedLanguage) | 2734 | void handleResponse(const std::string &translation, const std::string &detected_language) |
2734 | { | 2735 | { |
2735 | if (m_toLang != detectedLanguage) | 2736 | // filter out non-interesting responeses |
2736 | m_chat->mText += " (" + translation + ")"; | 2737 | if ( !translation.empty() |
2737 | 2738 | && (m_toLang != detected_language) | |
2738 | add_floater_chat(*m_chat, m_history); | 2739 | && (LLStringUtil::compareInsensitive(translation, m_origMesg) != 0) ) |
2740 | { | ||
2741 | m_chat.mText += " (" + translation + ")"; | ||
2742 | } | ||
2739 | 2743 | ||
2740 | delete m_chat; | 2744 | add_floater_chat(m_chat, m_history); |
2741 | } | 2745 | } |
2742 | 2746 | ||
2743 | void handleFailure() | 2747 | void handleFailure() |
2744 | { | 2748 | { |
2745 | LLTranslate::TranslationReceiver::handleFailure(); | 2749 | LLTranslate::TranslationReceiver::handleFailure(); |
2746 | 2750 | ||
2747 | m_chat->mText += " (?)"; | 2751 | m_chat.mText += " (?)"; |
2748 | 2752 | ||
2749 | add_floater_chat(*m_chat, m_history); | 2753 | add_floater_chat(m_chat, m_history); |
2750 | |||
2751 | delete m_chat; | ||
2752 | } | 2754 | } |
2753 | 2755 | ||
2754 | private: | 2756 | private: |
2755 | LLChat *m_chat; | 2757 | LLChat m_chat; |
2758 | std::string m_origMesg; | ||
2756 | const BOOL m_history; | 2759 | const BOOL m_history; |
2757 | }; | 2760 | }; |
2758 | 2761 | ||
@@ -2770,9 +2773,9 @@ void add_floater_chat(const LLChat &chat, const BOOL history) | |||
2770 | } | 2773 | } |
2771 | } | 2774 | } |
2772 | 2775 | ||
2773 | void check_translate_chat(const std::string &mesg, LLChat &chat, const BOOL history) | 2776 | void check_translate_chat(const std::string &mesg, const LLChat &chat, const BOOL history) |
2774 | { | 2777 | { |
2775 | const bool translate = LLUI::sConfigGroup->getBOOL("TranslateChat"); | 2778 | const bool translate = gSavedSettings.getBOOL("TranslateChat"); |
2776 | 2779 | ||
2777 | if (translate && chat.mSourceType != CHAT_SOURCE_SYSTEM) | 2780 | if (translate && chat.mSourceType != CHAT_SOURCE_SYSTEM) |
2778 | { | 2781 | { |
@@ -2780,9 +2783,8 @@ void check_translate_chat(const std::string &mesg, LLChat &chat, const BOOL hist | |||
2780 | // SVC-4879 | 2783 | // SVC-4879 |
2781 | const std::string &fromLang = ""; | 2784 | const std::string &fromLang = ""; |
2782 | const std::string &toLang = LLTranslate::getTranslateLanguage(); | 2785 | const std::string &toLang = LLTranslate::getTranslateLanguage(); |
2783 | LLChat *newChat = new LLChat(chat); | ||
2784 | 2786 | ||
2785 | LLHTTPClient::ResponderPtr result = ChatTranslationReceiver::build(fromLang, toLang, newChat, history); | 2787 | LLHTTPClient::ResponderPtr result = ChatTranslationReceiver::build(fromLang, toLang, chat, mesg, history); |
2786 | LLTranslate::translateMessage(result, fromLang, toLang, mesg); | 2788 | LLTranslate::translateMessage(result, fromLang, toLang, mesg); |
2787 | } | 2789 | } |
2788 | else | 2790 | else |
@@ -2961,8 +2963,9 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) | |||
2961 | std::string prefix = mesg.substr(0, 4); | 2963 | std::string prefix = mesg.substr(0, 4); |
2962 | if (prefix == "/me " || prefix == "/me'") | 2964 | if (prefix == "/me " || prefix == "/me'") |
2963 | { | 2965 | { |
2964 | chat.mText = from_name; | 2966 | const std::string spacer = mesg.substr(3,1); |
2965 | chat.mText += mesg.substr(3); | 2967 | mesg = mesg.substr(4); |
2968 | chat.mText = from_name + spacer + mesg; | ||
2966 | ircstyle = TRUE; | 2969 | ircstyle = TRUE; |
2967 | } | 2970 | } |
2968 | else | 2971 | else |
diff --git a/linden/indra/newview/llviewermessage.h b/linden/indra/newview/llviewermessage.h index 1a6c03b..11a3554 100644 --- a/linden/indra/newview/llviewermessage.h +++ b/linden/indra/newview/llviewermessage.h | |||
@@ -76,7 +76,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data); | |||
76 | void process_chat_from_simulator(LLMessageSystem *mesgsys, void **user_data); | 76 | void process_chat_from_simulator(LLMessageSystem *mesgsys, void **user_data); |
77 | 77 | ||
78 | void add_floater_chat(const LLChat &chat, const BOOL history); | 78 | void add_floater_chat(const LLChat &chat, const BOOL history); |
79 | void check_translate_chat(const std::string &mesg, LLChat &chat, const BOOL history); | 79 | void check_translate_chat(const std::string &mesg, const LLChat &chat, const BOOL history); |
80 | 80 | ||
81 | //void process_agent_to_new_region(LLMessageSystem *mesgsys, void **user_data); | 81 | //void process_agent_to_new_region(LLMessageSystem *mesgsys, void **user_data); |
82 | void send_agent_update(BOOL force_send, BOOL send_reliable = FALSE); | 82 | void send_agent_update(BOOL force_send, BOOL send_reliable = FALSE); |