Quantcast

uncomplete internationalization of 'auth' in admin panel

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

uncomplete internationalization of 'auth' in admin panel

Bugzilla from neostead@go2.pl
Internationalization of 'auth' app in django 1.2 isn't complete. In
user edit form there are user permissions displayed in two windows,
like "auth | permission | Can add permission", etc. I want it all
fully localized, but i can't digg up right code. Any ideas how to
solve that?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: uncomplete internationalization of 'auth' in admin panel

Dennis Kaarsemaker
On do, 2010-07-29 at 13:43 -0700, bagheera wrote:
> Internationalization of 'auth' app in django 1.2 isn't complete. In
> user edit form there are user permissions displayed in two windows,
> like "auth | permission | Can add permission", etc. I want it all
> fully localized, but i can't digg up right code. Any ideas how to
> solve that?

These strings do not come from the code but from the database.
Unfortunately django does not yet have a built-in mechanism for
internationalizing and translating those. There are third party addons
for this, though I have no idea whether they can be used for standard
django models.

--
Dennis K.

They've gone to plaid!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: uncomplete internationalization of 'auth' in admin panel

Bugzilla from neostead@go2.pl
Dnia 29-07-2010 o 23:17:13 Dennis Kaarsemaker <[hidden email]>  
napisał(a):

> On do, 2010-07-29 at 13:43 -0700, bagheera wrote:
>> Internationalization of 'auth' app in django 1.2 isn't complete. In
>> user edit form there are user permissions displayed in two windows,
>> like "auth | permission | Can add permission", etc. I want it all
>> fully localized, but i can't digg up right code. Any ideas how to
>> solve that?
>
> These strings do not come from the code but from the database.
> Unfortunately django does not yet have a built-in mechanism for
> internationalizing and translating those. There are third party addons
> for this, though I have no idea whether they can be used for standard
> django models.
>

Ok, with little help, we figure most of it out:
I had to modify django/contrib/auth/management/__init__.py

def _get_all_permissions(opts):
     "Returns (codename, name) for all permissions in the given opts."
     perms = []
     for action, action_pl in ( ('add', 'dodać'), ('change', 'zmienić'),  
('delete', 'usunąć') ):
         perms.append((_get_permission_codename(action, opts), u'Może %s  
%s' % (action_pl, opts.verbose_name_raw)))
     return perms + list(opts.permissions)

Now "Can add", and rest of it is translated during model creation

To use custom verbose name of 'auth' application i've created function

def get_verbose_name(app_label):
     try:
         return getattr(settings, "VERBOSE_APP_NAMES", {} ).get( app_label )
     except:
         return app_label

and changed django/contrib/auth/models.py


def __unicode__(self):
         verbose_name = get_verbose_name(self.content_type.app_label)
         return u"%s | %s | %s" % (
             unicode(verbose_name),
             unicode(self.content_type),
             unicode(self.name))

Now i only have one last element, model name, witch is raw, untranslated  
verbose_name. How to change that?

1. Should i change all verbose_name strings to static, nonlocalizable  
strings?
2. Should i modify view function to pass altered strings to template,  
witch view exactly?
3. Should i change verbose_name_raw property? How to do it right? It's  
located in db/models/options.py
4. Other suggestions

--
Linux user

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Loading...