#14806 closed New feature (fixed)
No template tag to support contextual translations
Reported by: | Jani Tiainen | Owned by: | Julien Phalip |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | i18n |
Cc: | claude@…, Craig Blaszczyk | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Implementation of #9988 provides only Python side solution. There is no built-in tag for contextual translations for templates.
Attachments (4)
Change History (17)
comment:1 by , 14 years ago
Summary: | No template tag to support con → No template tag to support contextual translations |
---|
comment:2 by , 14 years ago
Component: | Template system → Internationalization |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
milestone: | → 1.4 |
---|---|
Version: | 1.3-alpha → SVN |
Unfortunately we are in feature freeze mode, pushing to 1.4.
comment:4 by , 14 years ago
milestone: | 1.4 |
---|---|
Severity: | → Normal |
Type: | → New feature |
comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
UI/UX: | unset |
I'm working on this. Will post a patch soon.
comment:6 by , 13 years ago
herve (who reported #17045, a duplicate) is already working on a patch. He's "herve" on FreeNode too, you may want to check his status first.
comment:7 by , 13 years ago
Cc: | added |
---|
comment:8 by , 13 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
I've posted a work in progress. {% Blocktrans %}
and {% trans %}
are both implemented, although only there are only tests for {% blocktrans %}
at this stage. This will also need docs.
by , 13 years ago
Attachment: | 14806.template-tags-pgettext.diff added |
---|
by , 13 years ago
Attachment: | 14806.template-tags-pgettext.2.diff added |
---|
comment:9 by , 13 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
OK, I think that's it. Any feedback welcome. Thanks!
by , 13 years ago
Attachment: | 14806.template-tags-pgettext.3.diff added |
---|
comment:10 by , 13 years ago
The patch looks very good and the documentation is clear.
I have only one question: shouldn't this example read context "greeting"
rather than context="greeting"
? It looks inconsistent with the docstring of do_block_translate
and the regexps.
{% blocktrans with name=user.username context="greeting" %}Hi {{ name }}{% endblocktrans %}
Unfortunately, I couldn't apply the patch to my checkout, even with git apply
:
error: cannot apply binary patch to 'tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo' without full index line error: tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo: patch does not apply
As a consequence, my review is based on code inspection. I didn't run the tests, but they look solid.
by , 13 years ago
Attachment: | 14806.template-tags-pgettext.4.diff added |
---|
comment:11 by , 13 years ago
That's right, the syntax is context "xxx"
and not context="xxx"
-- I've fixed the doc example in the latest patch. I've also regenerated the *.mo file. I hope it works this time. Thanks for looking at the patch!
comment:13 by , 13 years ago
Cc: | added |
---|
Yeah, this would probably should look like this:
with blocktrans
with trans: