Skip to content

Commit 0febed8

Browse files
author
Alexander Smishlajev
committed
add translation to Unauthorised exception; mark missed text for translation
1 parent b0ccc87 commit 0febed8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

roundup/cgi/templating.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ class NoTemplate(Exception):
8787
pass
8888

8989
class Unauthorised(Exception):
90-
def __init__(self, action, klass):
90+
def __init__(self, action, klass, translator=None):
9191
self.action = action
9292
self.klass = klass
93+
if translator:
94+
self._ = translator.gettext
95+
else:
96+
self._ = translationService.gettext
9397
def __str__(self):
94-
return 'You are not allowed to %s items of class %s'%(self.action,
95-
self.klass)
98+
return self._('You are not allowed to %(action)s '
99+
'items of class %(class)s') % {
100+
'action': self.action, 'class': self.klass}
96101

97102
def find_template(dir, name, extension):
98103
''' Find a template in the nominated dir
@@ -681,7 +686,7 @@ def submit(self, label=''"Submit New Entry"):
681686

682687
def history(self):
683688
self.view_check()
684-
return 'New node - no history'
689+
return self._('New node - no history')
685690

686691
def renderWith(self, name, **kwargs):
687692
''' Render this class with the given template.

0 commit comments

Comments
 (0)