aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2011-12-28 17:58:22 +0100
committerWojciech Polak <polak@gnu.org>2011-12-28 17:59:33 +0100
commit3a7802735bdead4042c56f1fb6daaabb8271c347 (patch)
treeb72149d64609ed25ce366cd53a862455de6d9ec5
parentfe9b5bb56f9391a461d4ff89e8cc069b780b0df5 (diff)
downloadglifestream-3a7802735bdead4042c56f1fb6daaabb8271c347.tar.gz
glifestream-3a7802735bdead4042c56f1fb6daaabb8271c347.tar.bz2
Remove the translation feature.
-rw-r--r--static/js/glifestream.js21
-rw-r--r--stream/views.py20
-rw-r--r--templates/stream-pure.html1
-rw-r--r--utils/__init__.py3
-rw-r--r--utils/translate.py46
5 files changed, 2 insertions, 89 deletions
diff --git a/static/js/glifestream.js b/static/js/glifestream.js
index e9f5024..ca31c4c 100644
--- a/static/js/glifestream.js
+++ b/static/js/glifestream.js
@@ -250,19 +250,6 @@
return false;
}
- function translate_entry (e) {
- if (e) e.preventDefault ();
- var that = this;
- var id = this.id.split ('-')[1];
- show_spinner ($M (this));
- $.post (baseurl + 'api/translate', { entry: id }, function (html) {
- hide_spinner ();
- var ctx = $('#entry-'+ id +' .entry-content');
- ctx.html (html);
- alter_html (ctx);
- });
- }
-
function edit_entry (e) {
if (e) e.preventDefault ();
var that = this;
@@ -600,13 +587,6 @@
}
}
break;
- case 116: /* t */
- var ent = articles[current_article];
- if (ent) {
- var c = $('span.translate-control', ent);
- if (c.length) translate_entry.call (c[0]);
- }
- break;
}
}
@@ -717,7 +697,6 @@
$('span.favorite-control', stream).live ('click', favorite_entry);
$('span.hide-control', stream).live ('click', hide_entry);
- $('span.translate-control', stream).live ('click', translate_entry);
$('span.edit-control', stream).live ('click', edit_entry);
$('a.shareit', stream).live ('click', shareit_entry);
$('a.map', stream).each (render_map);
diff --git a/stream/views.py b/stream/views.py
index 4dc67dd..78b62d4 100644
--- a/stream/views.py
+++ b/stream/views.py
@@ -1,4 +1,4 @@
-# gLifestream Copyright (C) 2009, 2010 Wojciech Polak
+# gLifestream Copyright (C) 2009, 2010, 2011 Wojciech Polak
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -36,7 +36,6 @@ from glifestream.stream.models import Service, Entry, Favorite, List
from glifestream.stream import media, pshb
from glifestream.utils import common
from glifestream.utils.time import pn_month_start
-from glifestream.utils.translate import translate
from glifestream.apis import API_LIST, selfposts
try:
@@ -576,21 +575,4 @@ def api (request, **args):
except Exception:
pass
- elif cmd == 'translate':
- try:
- if entry:
- entry = Entry.objects.get (id=int(entry))
- if entry:
- accept_lang = request.META.get ('HTTP_ACCEPT_LANGUAGE',
- '').split (',')
- for i, lang in enumerate (accept_lang):
- accept_lang[i] = lang.split (';')[0]
-
- entry.content = translate (entry.content,
- target=accept_lang[0])
- content = fix_ampersands (gls_content ('', entry))
- return HttpResponse (content)
- except Exception:
- pass
-
return HttpResponse ()
diff --git a/templates/stream-pure.html b/templates/stream-pure.html
index a7b7f77..3aee469 100644
--- a/templates/stream-pure.html
+++ b/templates/stream-pure.html
@@ -38,7 +38,6 @@
<li><span tabindex="0" id="favorite-{{ entry.id }}" class="link favorite-control">{% trans "Favorite" %}</span></li>
{% endif %}
<li><span id="hide-{{ entry.id }}" class="link hide-control">{% trans "Hide" %}</span></li>
- <li><span id="translate-{{ entry.id }}" class="link translate-control">{% trans "Translate" %}</span></li>
<li><span id="edit-{{ entry.id }}" class="link edit-control">{% trans "Edit" %}</span></li>
<li><a href="{% url admin:index %}stream/entry/{{ entry.id }}" target="_blank">{% trans "Admin" %}</a></li>
</ul>
diff --git a/utils/__init__.py b/utils/__init__.py
index d3b5665..5d22ce4 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -1,4 +1,4 @@
-# gLifestream Copyright (C) 2009, 2010 Wojciech Polak
+# gLifestream Copyright (C) 2009, 2010, 2011 Wojciech Polak
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -19,5 +19,4 @@ __all__ = (
'httpclient',
'oembed',
'time',
- 'translate',
)
diff --git a/utils/translate.py b/utils/translate.py
deleted file mode 100644
index e76551b..0000000
--- a/utils/translate.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# gLifestream Copyright (C) 2009, 2010 Wojciech Polak
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from django.conf import settings
-from glifestream.utils import httpclient
-
-try:
- import json
-except ImportError:
- import simplejson as json
-
-def translate (msg, src='', target='en'):
- target = target.split ('-')[0]
- params = {
- 'v': '1.0',
- 'q': msg.encode ('utf_8'),
- 'langpair': src +'|'+ target,
- }
- headers = {
- 'Referer': settings.BASE_URL,
- }
-
- try:
- r = httpclient.urlopen ('ajax.googleapis.com/ajax/services/language/translate',
- params, headers, timeout=30)
- if r.code == 200:
- data = json.loads (r.data)
- if data['responseStatus'] == 200:
- return data['responseData']['translatedText']
- else:
- return data['responseDetails']
- except Exception:
- pass
- return ''

Return to:

Send suggestions and report system problems to the System administrator.