Dnia 29-07-2010 o 23:17:13 Dennis Kaarsemaker <den...@kaarsemaker.net> 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 django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to