Opened 10 years ago

Closed 10 years ago

#3970 closed (invalid)

Adding {{{as}}} keyword to {{{trans}}}

Reported by: axiak@… Owned by: hugo
Component: Internationalization Version: master
Severity: Keywords: i18n trans context tags
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently the {% trans ... %} tag allows for translating text to be rendered to the template. However, there are cases where allowing this to be written to the context for further processing is useful. An easy example was when a friend in IRC wanted to have multiple cases for the same phrase on the same page. He did not want to clutter his .po files with alternate case styles. He just wanted to use the provided filters on the translated text (for one case). The as keyword would be used like so:

{% trans "this is a test" as translated_text %}
{{ translated_text|upper }}

{{ translated_text|lower }}

Note that the noop keyword should still work:

{% trans "this is a test" as translated_text noop %}
{{ translated_text|upper }}

{{ translated_text|lower }}

I have written patches. Please let me know what you think!

Attachments (2)

118n-tags_3970.patch (3.2 KB) - added by axiak@… 10 years ago.
Alteration to templatetags/i18n.py for as keyword
i18n-docs_3970.patch (869 bytes) - added by axiak@… 10 years ago.
Corresponding documentation

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by axiak@…

Attachment: 118n-tags_3970.patch added

Alteration to templatetags/i18n.py for as keyword

Changed 10 years ago by axiak@…

Attachment: i18n-docs_3970.patch added

Corresponding documentation

comment:1 Changed 10 years ago by anonymous

Needs tests: set

comment:2 Changed 10 years ago by axiak@…

Resolution: invalid
Status: newclosed
{% blocktrans with "value"|upper as translated_title %}
Note: See TracTickets for help on using tickets.
Back to Top