Opened 12 years ago

Closed 10 years ago

#17246 closed Cleanup/optimization (wontfix)

title localization

Reported by: anonymous Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords: title main.py base.html
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

hi.
I am working on translation of my django app and i have one trouble
localized name of the model looks ugly when the template renders in admin page
in russian language the words have many variations that depends of context
for example I have 'user' model that translates as 'Пользователь'
but in context 'Select %s to change' it looks as 'Пользователя'

I can't override the base.html template because it gets {{ title }} variable that already incorrect in sentence context

I think that bulding of the strings like this must processed in template
for example in base.html:

was:

{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}

must:

{% block content_title %}{% if title %}<h1>Select {{ title }} to change'</h1>{% endif %}{% endblock %}

of course the result block will be bigger than in my example, but nevertheless this is more flexible approach.

Can you fix it?

Change History (7)

comment:1 by Aymeric Augustin, 12 years ago

Resolution: needsinfo
Status: newclosed

I'm sorry, but I don't grasp how the change you're proposing resolves the problem.

Won't {{ title }} still be defined by the verbose_name of your model?

Did I miss something?

comment:2 by Aymeric Augustin, 12 years ago

Resolution: needsinfo
Status: closedreopened

comment:3 by Aymeric Augustin, 12 years ago

Resolution: duplicate
Status: reopenedclosed

In fact this is a duplicate of #16973.

comment:4 by Aymeric Augustin, 12 years ago

Resolution: duplicate
Status: closedreopened
Triage Stage: UnreviewedAccepted

I'm no longer sure it was right to close this ticket. While I still don't understand the solution proposed by the OP, the problem looks valid.

This proposal could help fixing it.

comment:5 by Sergiy Kuzmenko, 12 years ago

The problem described here is string interpolation. In some languages simply sticking the verbose name into a template results in grammatically incorrect phrase.

Ramiro's proposal mentioned above does not really address this problem as it primarily deals with pluralization.

While this is a real problem, I'd say it should be marked as "won't fix" for 3 reasons:

1) Language generation is a rather non-trivial problem that is not specific to Django.

2) There is a simple but someone ugly workaround. Translators may choose to localize the offending template string in such a way that interpolating generic verbose form works for their locale. The resulting phrase often looks rather artificial but is at least grammatically correct (e.g., "Select object to change: user" instead of "Select user to change").

3) The proposed solution is ineffective. Whether we localize this in code (Select %s to change) or in template (Select {{ title }} to change) - the result is still the same.

comment:6 by Aymeric Augustin, 11 years ago

Status: reopenednew

comment:7 by Claude Paroz, 10 years ago

Resolution: wontfix
Status: newclosed

Closing as won't fix for now. As stated by shelldweller above, the best solution currently is to workaround this issue at the translation level, by reformulating the sentence (comment:5, point 2))

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