Test against Django 1.10b1 and dropped support for goslate and the Google translate API

This commit is contained in:
Marco Bonetti 2016-06-24 12:24:29 +02:00
parent b9427a0a74
commit ba44f3bf6b
8 changed files with 19 additions and 47 deletions

View file

@ -6,6 +6,8 @@ Version 0.7.12 (unreleased)
* Fix IndexError in fix_nls when translation is just a carriage return (PR #168, thanks @nealtodd)
* Remove float formatting of integer percent translated (PR #171, thanks @nealtodd)
* Fixed a comment (PR #170, thanks @dnaranjo89)
* Test against Django 1.10b1
* Dropped support for goslate and the Google translate API
Version 0.7.11

View file

@ -16,18 +16,6 @@ YANDEX_TRANSLATE_KEY = getattr(settings, 'YANDEX_TRANSLATE_KEY', None)
AZURE_CLIENT_ID = getattr(settings, 'AZURE_CLIENT_ID', None)
AZURE_CLIENT_SECRET = getattr(settings, 'AZURE_CLIENT_SECRET', None)
# Use Google translator
GOOGLE_TRANSLATE = getattr(settings, 'ROSETTA_GOOGLE_TRANSLATE', None)
if GOOGLE_TRANSLATE:
try:
import goslate # NOQA
import warnings
warnings.warn('Translation via Google Translate (goslate) is no longer supported by Google and will be removed in the next version of Rosetta')
except ImportError:
raise ImproperlyConfigured('If you set ROSETTA_GOOGLE_TRANSLATE to True, you must install the `goslate` module.')
# Displays this language beside the original MSGID in the admin
MAIN_LANGUAGE = getattr(settings, 'ROSETTA_MAIN_LANGUAGE', None)

View file

@ -101,7 +101,7 @@
</td>
<td class="translation">
{% for k, msgstr in message.msgstr_plural.items|dictsort:"0" %}
{% for k, msgstr in message.msgstr_plural.items %}
<label for="m_{{message.md5hash}}_{{k}}">{{k}}:</label>
<textarea rows="{{message.msgid|format_message|lines_count}}" cols="40" id="m_{{message.md5hash}}_{{k}}" name="m_{{message.md5hash}}_{{k}}" tabindex="{% increment tab_idx %}">{{msgstr}}</textarea>
{% endfor %}

View file

@ -3,7 +3,7 @@ from django.conf import settings
from django.core.urlresolvers import reverse, resolve
from django.core.exceptions import ImproperlyConfigured
from django.core.cache import cache
from django.test import TestCase # , override_settings
from django.test import TestCase
from django.test.client import Client
from django.dispatch import receiver
from rosetta.conf import settings as rosetta_settings
@ -17,7 +17,6 @@ import hashlib
class RosettaTestCase(TestCase):
urls = 'rosetta.tests.urls'
def __init__(self, *args, **kwargs):
super(RosettaTestCase, self).__init__(*args, **kwargs)
@ -56,7 +55,6 @@ class RosettaTestCase(TestCase):
self.__session_engine = settings.SESSION_ENGINE
self.__storage_class = rosetta_settings.STORAGE_CLASS
self.__require_auth = rosetta_settings.ROSETTA_REQUIRES_AUTH
self.__google_translate = rosetta_settings.GOOGLE_TRANSLATE
self.__enable_translation = rosetta_settings.ENABLE_TRANSLATION_SUGGESTIONS
self.__auto_compile = rosetta_settings.AUTO_COMPILE
@ -67,7 +65,6 @@ class RosettaTestCase(TestCase):
settings.SESSION_ENGINE = self.__session_engine
rosetta_settings.STORAGE_CLASS = self.__storage_class
rosetta_settings.ROSETTA_REQUIRES_AUTH = self.__require_auth
rosetta_settings.GOOGLE_TRANSLATE = self.__google_translate
rosetta_settings.ENABLE_TRANSLATION_SUGGESTIONS = self.__enable_translation
rosetta_settings.AUTO_COMPILE = self.__auto_compile
shutil.move(self.dest_file + '.orig', self.dest_file)
@ -694,14 +691,6 @@ class RosettaTestCase(TestCase):
self.assertTrue('<span class="message">translated-string1</span>' in str(r.content))
rosetta_settings.ENABLE_REFLANG = ENABLE_REFLANG
@vcr.use_cassette('fixtures/vcr_cassettes/test_33_pr_116_google_translate.yaml', match_on=['method', 'scheme', 'host', 'port', 'path', 'query', 'raw_body'], record_mode='new_episodes')
def test_33_pr_116_google_translate(self):
rosetta_settings.GOOGLE_TRANSLATE = True
rosetta_settings.ENABLE_TRANSLATION_SUGGESTIONS = True
r = self.client.get(reverse('translate_text') + '?from=en&to=fr&text=Hello,+world!')
self.assertTrue(six.text_type("Bonjour le monde!") in six.text_type(r.content))
def test_34_issue_113_app_configs(self):
if django.VERSION[0:2] >= (1, 7):
r = self.client.get(reverse('rosetta-pick-file') + '?filter=all')

View file

@ -3,8 +3,7 @@ from django.contrib.auth.decorators import user_passes_test
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.shortcuts import render
from django.utils.encoding import iri_to_uri
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.cache import never_cache
@ -298,7 +297,7 @@ def home(request):
except:
rosetta_i18n_lang_name = force_text(storage.get('rosetta_i18n_lang_name'))
return render_to_response('rosetta/pofile.html', dict(
return render(request, 'rosetta/pofile.html', dict(
version=rosetta.get_version(True),
ADMIN_MEDIA_PREFIX=ADMIN_MEDIA_PREFIX,
ADMIN_IMAGE_DIR=ADMIN_IMAGE_DIR,
@ -321,7 +320,7 @@ def home(request):
paginator=paginator,
rosetta_i18n_pofile=rosetta_i18n_pofile,
ref_lang=ref_lang,
), context_instance=RequestContext(request))
))
else:
return list_languages(request, do_session_warn=True)
@ -405,14 +404,14 @@ def list_languages(request, do_session_warn=False):
ADMIN_MEDIA_PREFIX = settings.STATIC_URL + 'admin/'
do_session_warn = do_session_warn and 'SessionRosettaStorage' in rosetta_settings.STORAGE_CLASS and 'signed_cookies' in settings.SESSION_ENGINE
return render_to_response('rosetta/languages.html', dict(
return render(request, 'rosetta/languages.html', dict(
version=rosetta.get_version(True),
ADMIN_MEDIA_PREFIX=ADMIN_MEDIA_PREFIX,
do_session_warn=do_session_warn,
languages=languages,
has_pos=has_pos,
rosetta_i18n_catalog_filter=rosetta_i18n_catalog_filter
), context_instance=RequestContext(request))
))
def get_app_name(path):
@ -485,14 +484,10 @@ def translate_text(request):
else:
# run the translation:
if getattr(rosetta_settings, 'GOOGLE_TRANSLATE', False):
import goslate
translator = goslate.Goslate()
else:
AZURE_CLIENT_ID = getattr(settings, 'AZURE_CLIENT_ID', None)
AZURE_CLIENT_SECRET = getattr(settings, 'AZURE_CLIENT_SECRET', None)
AZURE_CLIENT_ID = getattr(settings, 'AZURE_CLIENT_ID', None)
AZURE_CLIENT_SECRET = getattr(settings, 'AZURE_CLIENT_SECRET', None)
translator = Translator(AZURE_CLIENT_ID, AZURE_CLIENT_SECRET)
translator = Translator(AZURE_CLIENT_ID, AZURE_CLIENT_SECRET)
try:
translated_text = translator.translate(text, language_to, language_from)

View file

@ -112,6 +112,4 @@ ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage'
SECRET_KEY = 'empty'
ROSETTA_ENABLE_REFLANG = True
ROSETTA_GOOGLE_TRANSLATE = True
ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS = True

View file

@ -1,12 +1,11 @@
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^rosetta/', include('rosetta.urls'))
)
]
urlpatterns += staticfiles_urlpatterns()

View file

@ -1,7 +1,7 @@
[tox]
envlist =
py27-django17,
{py27,py35}-django{18,19},
{py27,py35}-django{18,19,110},
gettext,docs
skipsdist = True
@ -20,8 +20,9 @@ deps =
django17: Django==1.7.11
django18: Django==1.8.11
django19: Django==1.9.4
py27-django{17,18,19}: python-memcached
py35-django{17,18,19}: python3-memcached
django110: Django==1.10b1
py27-django{17,18,19,110}: python-memcached
py35-django{17,18,19,110}: python3-memcached
# py27-django18: pudb
requests
polib>=1.0.6