Opened 4 years ago

Closed 13 months 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 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

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 Changed 4 years ago by aaugustin

  • Resolution needsinfo deleted
  • Status changed from closed to reopened

comment:3 Changed 4 years ago by aaugustin

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

In fact this is a duplicate of #16973.

comment:4 Changed 4 years ago by aaugustin

  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 3 years ago by shelldweller

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 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:7 Changed 13 months ago by claudep

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

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