def test_translation(self): """Test if texts are translated.""" from django.utils.translation import override, force_unicode from synchro import call_synchronize msg_en = force_unicode(call_synchronize()) with override('pl'): self.assertNotEqual(msg_en, force_unicode(call_synchronize()))
def test_translation(self): """Test if texts are translated.""" from django.utils.translation import override, force_unicode from synchro import call_synchronize languages = ('en', 'pl', 'de', 'es', 'fr') messages = set() for lang in languages: with override(lang): messages.add(force_unicode(call_synchronize())) self.assertEqual(len(messages), len(languages), 'Some language is missing.')
def test_translation(self): """Test if texts are translated.""" from django.utils.translation import override from django.utils.encoding import force_unicode from synchro import call_synchronize languages = ('en', 'pl', 'de', 'es', 'fr') messages = set() for lang in languages: with override(lang): messages.add(force_unicode(call_synchronize())) self.assertEqual(len(messages), len(languages), 'Some language is missing.')
def synchro(request): if 'synchro' in request.POST: try: msg = call_synchronize() messages.add_message(request, messages.INFO, msg) except Exception as e: msg = _('An error occured: %(msg)s (%(type)s)') % {'msg': str(e), 'type': e.__class__.__name__} messages.add_message(request, messages.ERROR, msg) elif 'reset' in request.POST: reset_synchro() msg = _('Synchronization has been reset.') messages.add_message(request, messages.INFO, msg) return TemplateResponse(request, 'synchro.html', {'last': options.last_check})
def synchro(request): if 'synchro' in request.POST: try: msg = call_synchronize() messages.add_message(request, messages.INFO, msg) except Exception as e: if settings.DEBUG: raise msg = _('An error occured: %(msg)s (%(type)s)') % { 'msg': str(e), 'type': e.__class__.__name__ } messages.add_message(request, messages.ERROR, msg) elif 'reset' in request.POST and settings.ALLOW_RESET: reset_synchro() msg = _('Synchronization has been reset.') messages.add_message(request, messages.INFO, msg) return TemplateResponse(request, 'synchro.html', { 'last': options.last_check, 'reset_allowed': settings.ALLOW_RESET })