Opened 16 years ago
Last modified 11 years ago
#10436 closed
Application names i18n in the admin app broken — at Version 6
Reported by: | Ramiro Morales | Owned by: | Ramiro Morales |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | blocktrans trans app_label breadcrumbs capfirst title app-loading |
Cc: | Ben Spaulding, Jannis Leidel, basti@…, someuniquename@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Having
{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}
as we currently do in some admin templates shows a decision has been made to allow developers the ability translate application names.
Problem is this feature was DOA (r3270, django/contrib/admin/templates/admin/index.html
, similar template code was copied since then to another file: r8474, app_index.html
)
See relevant django-users and django-i18n threads for the details.
The attached patch implements as a fix the awkward manual steps needed to workaround this bug outlined by the user patrikk in the first thread, plus the following enhancements:
index
,app_index
: Moved the markup-as-translatable of app names from the template to the view code so the translators aren't forced to translate a secondtitle()
'd version of every app name.- Consistent use of the
capfirst
filter on the app names in the breadcrumbs of the different views. - Don't touch
base_site.html
in order to provide for translatability of the app name in the<title>
HTML tag for the application-specific model list view. Instead, implement the needed change in the relevant view (app_index
) (replacing a"%s administration"
msgid with a more translator-friendly"%(app_label)s administration"
one in the process). This will spare translators the need to translate both a"<appname>"
and a"<appname> administration"
literals. - Extend above fixes to other templates that also need them (
delete_confirm.html
,object_history.html
)
Notes to reviewers:
Note 1: This patch has nothing to do with the decision of how we will allow the app name metadata to be specified and marked as translatable in the app itself, that seems to be a new feature I'm sure is being dealt with in other tickets. This ticket is much less ambitious: it's about fixing an old internationalization bug in the presentation of that information (irrespective of its origin in the backend) in the admin contrib app.
Note 2: The change_form.html
template ran the app label through the escape
filter. This has been dropped because it seems inconsistent with what is done in rest of the templates, the app name isn't end user-provided content so the risk of being abused for XSS seems low.
Note 3: There seems to be some inconsistency on how the app name is a) .title()
'd for the name that appear in the caption of model tables (index
and app_index
views) and b) |capfirst
'd for use in HTML title and breadcrumbs. This has been left untouched to avoid introducing a backward incompatible change.
Note 4: A further enhancement would be to move presentation-related munging (like calling .title()
and/or capfirst()
in view code) from views to templates if/when #5972 gets committed but meanwhile this fix can solve this bug now with the tools we have at hand now.
Several of the problems exposed above had already been reported in #9273.
Change History (10)
by , 16 years ago
Attachment: | 10436-app-name-translation-in-admin-r9998.diff added |
---|
comment:1 by , 16 years ago
Summary: | Application names i10n in the admin app broken → Application names i18n in the admin app broken |
---|
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 16 years ago
Cc: | added |
---|
comment:4 by , 16 years ago
Description: | modified (diff) |
---|
by , 16 years ago
Attachment: | 10436-app-name-translation-in-admin-r10283.diff added |
---|
Patch updated to trunk post-bulk-edit and post-r10234
comment:5 by , 16 years ago
Has patch: | set |
---|
by , 16 years ago
Attachment: | 10436-app-name-translation-in-admin-r10314.diff added |
---|
Patch with some fixes to the patch iself
by , 15 years ago
Attachment: | 10436-app-name-translation-in-admin-r11581.diff added |
---|
Patch updated to trunk as of r11581
(made description more clear)