Commits

Simone Marzola committed b7f9e74

fix: perform gettext call on constant strings

Comments (0)

Files changed (1)

tgcomments/controllers/root.py

 
 def back_to_referer(message=None, status='ok'):
     if message:
-        flash(_(message), status)
+        flash(message, status)
     if request.referer is not None:
         raise redirect(request.referer)
     raise redirect(request.host_url)
         entity_type = getattr(app_model, kw['entity_type'], None)
         entity_id = kw['entity_id']
         if entity_type is None or entity_id is None:
-            return back_to_referer('Failed to post comment', status='error')
+            return back_to_referer(_('Failed to post comment'), status='error')
 
         if issubclass(entity_type, FakeCommentEntity):
             entity = make_fake_comment_entity(entity_type, entity_id)
         else:
             entity = DBSession.query(entity_type).get(entity_id)
             if not entity:
-                return back_to_referer('Failed to post comment', status='error')
+                return back_to_referer(_('Failed to post comment'), status='error')
 
         if not request.identity:
             try:
                 user = {'name':String(not_empty=True).to_python(kw.get('author')),
                         'avatar':get_user_gravatar(Email(not_empty=True).to_python(kw.get('email')))}
             except Invalid:
-                return back_to_referer('Failed to post comment', status='error')
+                return back_to_referer(_('Failed to post comment'), status='error')
         else:
             user = request.identity['user']
 
         c = Comment.add_comment(entity, user, kw['body'])
         notify_comment_on_facebook(request.referer, c)
-        return back_to_referer('Comment Added')
+        return back_to_referer(_('Comment Added'))
 
     @expose()
     @require(predicates.in_group('tgcmanager'))
               error_handler=fail_with(404))
     def delete(self, comment):
         DBSession.delete(comment)
-        return back_to_referer('Comment Deleted')
+        return back_to_referer(_('Comment Deleted'))
 
     @expose()
     @require(predicates.in_group('tgcmanager'))
     def hide(self, comment):
         comment.hidden = not comment.hidden
         if comment.hidden:
-            return back_to_referer('Comment Hidden')
-        return back_to_referer('Comment Displayed')
+            return back_to_referer(_('Comment Hidden'))
+        return back_to_referer(_('Comment Displayed'))
 
     @expose()
     @require(predicates.not_anonymous())
             DBSession.flush()
         except IntegrityError:
             transaction.doom()
-            return back_to_referer('Already voted this comment', 'warning')
-        return back_to_referer('Thanks for your vote!')
+            return back_to_referer(_('Already voted this comment'), 'warning')
+        return back_to_referer(_('Thanks for your vote!'))