[kupfer] google_translate: Join multiple sentences in result
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] google_translate: Join multiple sentences in result
- Date: Mon, 11 Jan 2010 22:52:16 +0000 (UTC)
commit 68557cd9485da714bdd8dfecb66bb1f774966c74
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Jan 11 23:44:31 2010 +0100
google_translate: Join multiple sentences in result
If we translate a long text, we receive an array of sentences from
Google. We join them up into the final text.
This bug was reported by @hetdegon.
kupfer/plugin/google_translate.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugin/google_translate.py b/kupfer/plugin/google_translate.py
index 8929380..3f68528 100644
--- a/kupfer/plugin/google_translate.py
+++ b/kupfer/plugin/google_translate.py
@@ -74,10 +74,10 @@ def _translate(text, lang):
sentences = resp.get('sentences')
if not sentences:
return
- translation = sentences[0].get('trans')
- if not translation:
- return
- yield translation, ''
+ # Join up all sentences to one text
+ text = u"".join(filter(None, [S.get('trans') for S in sentences]))
+ if text:
+ yield text, ''
dictionary = resp.get('dict')
if dictionary:
for term in dictionary:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]