Ticket #11105: translate_permissions.diff

File translate_permissions.diff, 1.6 KB (added by Henrique C. Alves, 16 years ago)

Fix for this particular case - just to keep track

  • .py

    old new  
    44
    55from django.db.models import get_models, signals
    66from django.contrib.auth import models as auth_app
     7from django.utils.translation import ugettext as _
     8from django.utils.encoding import force_unicode
     9
    710
    811def _get_permission_codename(action, opts):
    912    return u'%s_%s' % (action, opts.object_name.lower())
     
    1114def _get_all_permissions(opts):
    1215    "Returns (codename, name) for all permissions in the given opts."
    1316    perms = []
    14     for action in ('add', 'change', 'delete'):
    15         perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))
     17    default_actions = (
     18        ('add', _(u'Can add %(name)s') % {'name': opts.verbose_name_raw}),
     19        ('change', _(u'Can change %(name)s') % {'name': opts.verbose_name_raw}),
     20        ('delete', _(u'Can delete %(name)s') % {'name': opts.verbose_name_raw}),
     21    )
     22    for action, name in default_actions:
     23        perms.append((_get_permission_codename(action, opts),
     24            force_unicode(name)))
    1625    return perms + list(opts.permissions)
    1726
    1827def create_permissions(app, created_models, verbosity, **kwargs):
    1928    from django.contrib.contenttypes.models import ContentType
    2029    from django.contrib.auth.models import Permission
     30    from django.utils.translation import activate
     31    from django.conf import settings
     32    activate(settings.LANGUAGE_CODE)
    2133    app_models = get_models(app)
    2234    if not app_models:
    2335        return
Back to Top