Opened 4 years ago

Closed 4 years ago

#14450 closed (duplicate)

Simple but powerfull patch to make application name localizable

Reported by: nnseva 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: UI/UX:

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 nnseva 4 years ago.
More places to patch on other pages
options.py.patch (5.4 KB) - added by nnseva 4 years ago.
Yet more places to patch
actions.py.patch (952 bytes) - added by nnseva 4 years ago.
Patch for "Delete selected" action
templates.admin.patch (2.8 KB) - added by nnseva 4 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 nnseva 4 years ago.
All-in-one patch to use INSTEAD of the previously-submitted separate patches

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by nnseva

More places to patch on other pages

Changed 4 years ago by nnseva

Yet more places to patch

Changed 4 years ago by nnseva

Patch for "Delete selected" action

Changed 4 years ago by nnseva

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

comment:1 Changed 4 years ago by nnseva

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

Changed 4 years ago by nnseva

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

comment:2 Changed 4 years ago by jezdez

  • Resolution set to duplicate
  • Status changed from new to closed

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