Ticket #14450: localization-for-application-name.patch

File 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

  • contrib/admin/actions.py

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/actions.py ./contrib/admin/actions.py
    old new  
    1212from django.utils.safestring import mark_safe
    1313from django.utils.text import capfirst
    1414from django.utils.translation import ugettext_lazy, ugettext as _
     15from django.conf import settings
    1516
    1617def delete_selected(modeladmin, request, queryset):
    1718    """
     
    2526    """
    2627    opts = modeladmin.model._meta
    2728    app_label = opts.app_label
     29    app_name = app_label.title()
     30    try:
     31        app_name = settings.APP_NAMES[app_label]
     32    except:
     33        pass
    2834
    2935    # Check that the user has delete permission for the actual model
    3036    if not modeladmin.has_delete_permission(request):
     
    6066        "opts": opts,
    6167        "root_path": modeladmin.admin_site.root_path,
    6268        "app_label": app_label,
     69        "app_name": app_name,
    6370        'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
    6471    }
    6572
  • contrib/admin/options.py

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/options.py ./contrib/admin/options.py
    old new  
    2323from django.utils.translation import ugettext as _
    2424from django.utils.translation import ungettext, ugettext_lazy
    2525from django.utils.encoding import force_unicode
     26from django.conf import settings
    2627
    2728HORIZONTAL, VERTICAL = 1, 2
    2829# returns the <ul> class for a given radio_admin field
     
    265266    urls = property(urls)
    266267
    267268    def _media(self):
    268         from django.conf import settings
    269 
    270269        js = ['js/core.js', 'js/admin/RelatedObjectLookups.js',
    271270              'js/jquery.min.js', 'js/jquery.init.js']
    272271        if self.actions is not None:
     
    605604    def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
    606605        opts = self.model._meta
    607606        app_label = opts.app_label
     607        app_name = app_label.title()
     608        try:
     609            app_name = settings.APP_NAMES[app_label]
     610        except:
     611            pass
    608612        ordered_objects = opts.get_ordered_objects()
    609613        context.update({
    610614            'add': add,
     
    617621            'ordered_objects': ordered_objects,
    618622            'form_url': mark_safe(form_url),
    619623            'opts': opts,
     624            'app_name': app_name,
    620625            'content_type_id': ContentType.objects.get_for_model(self.model).id,
    621626            'save_as': self.save_as,
    622627            'save_on_top': self.save_on_top,
     
    836841            inline_admin_formsets.append(inline_admin_formset)
    837842            media = media + inline_admin_formset.media
    838843
     844        app_name = opts.app_label.title()
     845        try:
     846            app_name = settings.APP_NAMES[app_label]
     847        except:
     848            pass
     849
    839850        context = {
    840851            'title': _('Add %s') % force_unicode(opts.verbose_name),
    841852            'adminform': adminForm,
     
    846857            'errors': helpers.AdminErrorList(form, formsets),
    847858            'root_path': self.admin_site.root_path,
    848859            'app_label': opts.app_label,
     860            'app_name': app_name,
    849861        }
    850862        context.update(extra_context or {})
    851863        return self.render_change_form(request, context, form_url=form_url, add=True)
     
    927939            inline_admin_formsets.append(inline_admin_formset)
    928940            media = media + inline_admin_formset.media
    929941
     942        app_name = opts.app_label.title()
     943        try:
     944            app_name = settings.APP_NAMES[app_label]
     945        except:
     946            pass
     947
    930948        context = {
    931949            'title': _('Change %s') % force_unicode(opts.verbose_name),
    932950            'adminform': adminForm,
     
    938956            'errors': helpers.AdminErrorList(form, formsets),
    939957            'root_path': self.admin_site.root_path,
    940958            'app_label': opts.app_label,
     959            'app_name': app_name,
    941960        }
    942961        context.update(extra_context or {})
    943962        return self.render_change_form(request, context, change=True, obj=obj)
     
    948967        from django.contrib.admin.views.main import ERROR_FLAG
    949968        opts = self.model._meta
    950969        app_label = opts.app_label
     970
     971        app_name = opts.app_label.title()
     972        try:
     973            app_name = settings.APP_NAMES[app_label]
     974        except:
     975            pass
     976
    951977        if not self.has_change_permission(request, None):
    952978            raise PermissionDenied
    953979
     
    10771103            'has_add_permission': self.has_add_permission(request),
    10781104            'root_path': self.admin_site.root_path,
    10791105            'app_label': app_label,
     1106            'app_name': app_name,
    10801107            'action_form': action_form,
    10811108            'actions_on_top': self.actions_on_top,
    10821109            'actions_on_bottom': self.actions_on_bottom,
     
    10951122        "The 'delete' admin view for this model."
    10961123        opts = self.model._meta
    10971124        app_label = opts.app_label
     1125        app_name = opts.app_label.title()
     1126        try:
     1127            app_name = settings.APP_NAMES[app_label]
     1128        except:
     1129            pass
    10981130
    10991131        obj = self.get_object(request, unquote(object_id))
    11001132
     
    11301162            "opts": opts,
    11311163            "root_path": self.admin_site.root_path,
    11321164            "app_label": app_label,
     1165            "app_name": app_name,
    11331166        }
    11341167        context.update(extra_context or {})
    11351168        context_instance = template.RequestContext(request, current_app=self.admin_site.name)
     
    11451178        model = self.model
    11461179        opts = model._meta
    11471180        app_label = opts.app_label
     1181        app_name = opts.app_label.title()
     1182        try:
     1183            app_name = settings.APP_NAMES[app_label]
     1184        except:
     1185            pass
    11481186        action_list = LogEntry.objects.filter(
    11491187            object_id = object_id,
    11501188            content_type__id__exact = ContentType.objects.get_for_model(model).id
     
    11581196            'object': obj,
    11591197            'root_path': self.admin_site.root_path,
    11601198            'app_label': app_label,
     1199            'app_name': app_name,
    11611200        }
    11621201        context.update(extra_context or {})
    11631202        context_instance = template.RequestContext(request, current_app=self.admin_site.name)
     
    12241263            self.verbose_name_plural = self.model._meta.verbose_name_plural
    12251264
    12261265    def _media(self):
    1227         from django.conf import settings
    12281266        js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/inlines.min.js']
    12291267        if self.prepopulated_fields:
    12301268            js.append('js/urlify.js')
  • contrib/admin/sites.py

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/sites.py ./contrib/admin/sites.py
    old new  
    370370                    if app_label in app_dict:
    371371                        app_dict[app_label]['models'].append(model_dict)
    372372                    else:
     373                        app_name = app_label.title()
     374                        try:
     375                            app_name = settings.APP_NAMES[app_label]
     376                        except:
     377                            pass
    373378                        app_dict[app_label] = {
    374                             'name': app_label.title(),
     379                            'name': app_name,
    375380                            'app_url': app_label + '/',
    376381                            'has_module_perms': has_module_perms,
    377382                            'models': [model_dict],
     
    415420        user = request.user
    416421        has_module_perms = user.has_module_perms(app_label)
    417422        app_dict = {}
     423        app_name = capfirst(app_label)
     424        try:
     425            app_name = settings.APP_NAMES[app_label]
     426        except:
     427            pass
    418428        for model, model_admin in self._registry.items():
    419429            if app_label == model._meta.app_label:
    420430                if has_module_perms:
     
    435445                            # something to display, add in the necessary meta
    436446                            # information.
    437447                            app_dict = {
    438                                 'name': app_label.title(),
     448                                'name': app_name,
    439449                                'app_url': '',
    440450                                'has_module_perms': has_module_perms,
    441451                                'models': [model_dict],
     
    445455        # Sort the models alphabetically within each app.
    446456        app_dict['models'].sort(lambda x, y: cmp(x['name'], y['name']))
    447457        context = {
    448             'title': _('%s administration') % capfirst(app_label),
     458            'title': _('%s administration') % app_name,
    449459            'app_list': [app_dict],
    450460            'root_path': self.root_path,
    451461        }
  • contrib/admin/templates/admin/change_form.html

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/templates/admin/change_form.html ./contrib/admin/templates/admin/change_form.html
    old new  
    1111
    1212{% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}
    1313
    14 {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
     14{% block bodyclass %}{{ app_name }}-{{ opts.object_name.lower }} change-form{% endblock %}
    1515
    1616{% block breadcrumbs %}{% if not is_popup %}
    1717<div class="breadcrumbs">
    1818     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
    19      <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
     19     <a href="../../">{{ app_name|escape }}</a> &rsaquo;
    2020     {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
    2121     {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
    2222</div>
  • contrib/admin/templates/admin/change_list.html

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/templates/admin/change_list.html ./contrib/admin/templates/admin/change_list.html
    old new  
    4343      </a>
    4444       &rsaquo;
    4545       <a href="../">
    46          {{ app_label|capfirst }}
     46         {{ app_name }}
    4747      </a>
    4848      &rsaquo;
    4949      {{ cl.opts.verbose_name_plural|capfirst }}
  • contrib/admin/templates/admin/delete_confirmation.html

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/templates/admin/delete_confirmation.html ./contrib/admin/templates/admin/delete_confirmation.html
    old new  
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66     <a href="../../../../">{% trans "Home" %}</a> &rsaquo;
    7      <a href="../../../">{{ app_label|capfirst }}</a> &rsaquo;
     7     <a href="../../../">{{ app_name }}</a> &rsaquo;
    88     <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
    99     <a href="../">{{ object|truncatewords:"18" }}</a> &rsaquo;
    1010     {% trans 'Delete' %}
  • contrib/admin/templates/admin/delete_selected_confirmation.html

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/templates/admin/delete_selected_confirmation.html ./contrib/admin/templates/admin/delete_selected_confirmation.html
    old new  
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66     <a href="../../">{% trans "Home" %}</a> &rsaquo;
    7      <a href="../">{{ app_label|capfirst }}</a> &rsaquo;
     7     <a href="../">{{ app_name }}</a> &rsaquo;
    88     <a href="./">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
    99     {% trans 'Delete multiple objects' %}
    1010</div>
  • contrib/admin/templates/admin/object_history.html

    diff -u -r -x '*.pyc' -x '*.patch' /home/seva/django.orig/lib/python2.6/site-packages/django/contrib/admin/templates/admin/object_history.html ./contrib/admin/templates/admin/object_history.html
    old new  
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66    <a href="../../../../">{% trans 'Home' %}</a> &rsaquo;
    7     <a href="../../../">{{ app_label|capfirst }}</a> &rsaquo;
     7    <a href="../../../">{{ app_name }}</a> &rsaquo;
    88    <a href="../../">{{ module_name }}</a> &rsaquo;
    99    <a href="../">{{ object|truncatewords:"18" }}</a> &rsaquo;
    1010    {% trans 'History' %}
Back to Top