This commit is contained in:
Marco Bonetti 2013-12-26 14:59:23 +01:00
parent 5304595cd7
commit 4d8afd8e5b
5 changed files with 14 additions and 25 deletions

View file

@ -7,6 +7,7 @@ Version 0.7.3
* Added support for the Azure translation API, replacing the BING API. (Issue #86, thanks @davidkuchar and @maikelwever)
* Removed support for the signed_cookies SESSION_ENGINE + SessionRosettaStorage in Django 1.6, because serialization of POFiles would fail
* Simplified the group membership test (Issue #90 - Thanks @dotsbb)
* Dropped Django 1.3 support
Version 0.7.2
-------------

View file

@ -4,6 +4,7 @@ exclude *.pyc
exclude *.sh
recursive-include rosetta/locale *
recursive-include rosetta/tests *
recursive-include rosetta/utils *
recursive-include rosetta/templates *
prune testproject
prune rosetta/tests/__pycache__

View file

@ -1,12 +1,12 @@
<!DOCTYPE html>{% load url from future %}
<!DOCTYPE html>{% load url from future %}{% load admin_static %}
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{% block pagetitle %}Rosetta{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="{{ADMIN_MEDIA_PREFIX}}css/base.css" type="text/css"/>
<link rel="stylesheet" href="{{ADMIN_MEDIA_PREFIX}}css/forms.css" type="text/css"/>
<link rel="stylesheet" href="{{ADMIN_MEDIA_PREFIX}}css/changelists.css" type="text/css"/>
<link rel="stylesheet" href="{% static "admin/css/base.css" %}" type="text/css"/>
<link rel="stylesheet" href="{% static "admin/css/forms.css" %}" type="text/css"/>
<link rel="stylesheet" href="{% static "admin/css/changelists.css" %}" type="text/css"/>
<style type="text/css" media="screen">
{% include 'rosetta/css/rosetta.css' %}
</style>

View file

@ -156,7 +156,7 @@ def home(request):
post_save.send(sender=None, language_code=rosetta_i18n_lang_code, request=request)
# Try auto-reloading via the WSGI daemon mode reload mechanism
if rosetta_settings.WSGI_AUTO_RELOAD and \
if rosetta_settings.WSGI_AUTO_RELOAD and \
'mod_wsgi.process_group' in request.environ and \
request.environ.get('mod_wsgi.process_group', None) and \
'SCRIPT_FILENAME' in request.environ and \
@ -338,7 +338,7 @@ def list_languages(request, do_session_warn=False):
languages.append(
(language[0],
_(language[1]),
sorted([(get_app_name(l), os.path.realpath(l), pofile(l)) for l in pos], key=lambda app: app[0]),
sorted([(get_app_name(l), os.path.realpath(l), pofile(l)) for l in pos], key=lambda app: app[0]),
)
)
try:
@ -382,7 +382,7 @@ def lang_sel(request, langid, idx):
storage.set('rosetta_i18n_lang_code', langid)
storage.set('rosetta_i18n_lang_name', six.text_type([l[1] for l in settings.LANGUAGES if l[0] == langid][0]))
storage.set('rosetta_i18n_fn', file_)
storage.set('rosetta_i18n_fn', file_)
po = pofile(file_)
for entry in po:
entry.md5hash = hashlib.new('md5',
@ -400,13 +400,15 @@ def lang_sel(request, langid, idx):
return HttpResponseRedirect(reverse('rosetta-home'))
@user_passes_test(lambda user: can_translate(user), settings.LOGIN_URL)
def translate_text(request):
language_from = request.GET.get('from', None)
language_to = request.GET.get('to', None)
text = request.GET.get('text', None)
if language_from == language_to:
data = { 'success' : True, 'translation' : text }
data = {'success': True, 'translation': text}
else:
# run the translation:
AZURE_CLIENT_ID = getattr(settings, 'AZURE_CLIENT_ID', None)
@ -416,8 +418,8 @@ def translate_text(request):
try:
translated_text = translator.translate(text, language_to)
data = { 'success' : True, 'translation' : translated_text }
data = {'success': True, 'translation': translated_text}
except TranslateApiException as e:
data = { 'success' : False, 'error' : "Translation API Exception: {0}".format(e.message) }
data = {'success': False, 'error': "Translation API Exception: {0}".format(e.message)}
return HttpResponse(json.dumps(data), mimetype='application/json')

View file

@ -1,12 +1,5 @@
#!/bin/bash
if [ ! -d .venv_13 ]
then
virtualenv --no-site-packages --distribute --python=python2 .venv_13
. .venv_13/bin/activate
pip install --use-mirrors Django==1.3 coverage python-memcached six requests==2.1.0
deactivate
fi
if [ ! -d .venv_14 ]
then
virtualenv --no-site-packages --distribute --python=python2 .venv_14
@ -43,14 +36,6 @@ then
deactivate
fi
. .venv_13/bin/activate
cd testproject
python manage.py --version
python --version
python manage.py test rosetta
cd ..
deactivate
. .venv_14/bin/activate
cd testproject
python manage.py --version