Opened 14 years ago

Closed 14 years ago

#14450 closed (duplicate)

Simple but powerfull patch to make application name localizable

Reported by: Vsevolod Novikov Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The applied patch is used to make application names localizable for admin interface and also for other purposes.

This patch is applied to django v. 1.2.3 (django.VERSION = (1, 2, 3, 'final', 0))

It uses a new APP_NAMES variable from the user-provided settings.py which should be a dictionary having application label (model._meta.app_label) as a key, and application verbose name as a value. If the APP_NAMES is absent or doesn't contain a label of the application, the old schema (app_label.Title()) is used.

This way allows to localize application names exactly as other things in the project:

settings.py:

...
from django.utils.translation import ugettext_lazy as _
...
INSTALLED_APPS = (                                                                                                                                             
    ...
    'myapp.service',                                                                                                                                        
    ...
)                                                                                                                                                              
                                                                                                                                                               
APP_NAMES = {                                                                                                                                                  
    'service':_('Service')                                                                                                                                     
}                                                                                                                                                              

Now the "Service" string will appear in the django.po files for the whole project, so you can localize application names as you wish.

This patch is a minimalistic way to make a part of the job made by the patch published in the ticket #3591. Reasons why I've published the patch is - "simpler means more stable", and "One patch - one job".

Attachments (5)

sites.py.patch (2.1 KB ) - added by Vsevolod Novikov 14 years ago.
More places to patch on other pages
options.py.patch (5.4 KB ) - added by Vsevolod Novikov 14 years ago.
Yet more places to patch
actions.py.patch (952 bytes ) - added by Vsevolod Novikov 14 years ago.
Patch for "Delete selected" action
templates.admin.patch (2.8 KB ) - added by Vsevolod Novikov 14 years ago.
Patch for admin templates to use a new app_name variable introduced in *.py.patch
localization-for-application-name.patch (13.4 KB ) - added by Vsevolod Novikov 14 years ago.
All-in-one patch to use INSTEAD of the previously-submitted separate patches

Download all attachments as: .zip

Change History (7)

by Vsevolod Novikov, 14 years ago

Attachment: sites.py.patch added

More places to patch on other pages

by Vsevolod Novikov, 14 years ago

Attachment: options.py.patch added

Yet more places to patch

by Vsevolod Novikov, 14 years ago

Attachment: actions.py.patch added

Patch for "Delete selected" action

by Vsevolod Novikov, 14 years ago

Attachment: templates.admin.patch added

Patch for admin templates to use a new app_name variable introduced in *.py.patch

comment:1 by Vsevolod Novikov, 14 years ago

Note that the web interface doesn't show all patched files in the templates.admin.patch for unknown reason - download the patch file instead to see all changes

by Vsevolod Novikov, 14 years ago

All-in-one patch to use INSTEAD of the previously-submitted separate patches

comment:2 by Jannis Leidel, 14 years ago

Resolution: duplicate
Status: newclosed

This is very much related to #3591 and this year's Google Summer of Code project about the app loading that deals with the fact that app_labels are used improperly in a lot of places in Django. Translating the app names is one feature included in that branch which is slated to be worked in 1.4.

Note: See TracTickets for help on using tickets.
Back to Top