[Django] #24230: Filter: language_translated returns translated name of language

18 views
Skip to first unread message

Django

unread,
Jan 27, 2015, 3:46:12 PM1/27/15
to django-...@googlegroups.com
#24230: Filter: language_translated returns translated name of language
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner: nobody
Type: New feature | Status: new
Component: | Version: master
Internationalization | Keywords: filter tag translated
Severity: Normal | language lang_code
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
`get_language_info` tag returns english name and local name of language:

{{{
language.local_name == česky
language.name == Czech
}}}

Neither depends on active language, but sometimes there's need for
translated language name, ex. tchèque (in French). The only way how to do
it right now is to take the english name and run it through `gettext`
since Django already has all languages translated.

This would be very handy filter tag:

{{{
@register.filter
def language_translated(code):
"""
Return language name translated into active language
"""

name = translation.get_language_info(code)['name'].capitalize()
return translation.gettext(name)
}}}

----

Maybe we could also extend dictionary returned by the `get_language_info`
tag with `name_translated` to keep API consistent. All keys from
`get_language_info` have matching filter variants (`language_name`,
`language_name_local` and `language_bidi`).

--
Ticket URL: <https://code.djangoproject.com/ticket/24230>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 27, 2015, 6:19:19 PM1/27/15
to django-...@googlegroups.com
#24230: Filter: language_translated returns translated name of language
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner: nobody
Type: New feature | Status: new
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: filter tag | Triage Stage: Accepted
translated language lang_code |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by wimfeijen):

* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

Accepted because not all people are English.

--
Ticket URL: <https://code.djangoproject.com/ticket/24230#comment:1>

Django

unread,
Jan 28, 2015, 4:57:27 AM1/28/15
to django-...@googlegroups.com
#24230: Add language name translated into active language to LANG_INFO dictionary
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner:
| tricoder42
Type: New feature | Status: assigned

Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: filter tag | Triage Stage: Accepted
translated language lang_code |
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tricoder42):

* status: new => assigned
* needs_tests: 0 => 1
* owner: nobody => tricoder42
* needs_docs: 0 => 1
* has_patch: 0 => 1


Comment:

Added PR https://github.com/django/django/pull/3997 with proposal.

I'm not sure if we should name it `name_translated`. It's a bit log and it
would make sense to simply translate `name` directly. However, that would
be backward incompatible. Add new item to LANG_INFO dictionary is less
invasive.

Missing documentation update and tests for filter.

--
Ticket URL: <https://code.djangoproject.com/ticket/24230#comment:2>

Django

unread,
Mar 28, 2015, 4:56:27 AM3/28/15
to django-...@googlegroups.com
#24230: Add language name translated into active language to LANG_INFO dictionary
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner:
| tricoder42
Type: New feature | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: filter tag | Triage Stage: Accepted
translated language lang_code |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24230#comment:3>

Django

unread,
May 31, 2015, 10:41:21 AM5/31/15
to django-...@googlegroups.com
#24230: Add language name translated into active language to LANG_INFO dictionary
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner:
| tricoder42
Type: New feature | Status: assigned
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: filter tag | Triage Stage: Accepted
translated language lang_code |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tricoder42):

* needs_docs: 1 => 0


Comment:

Documentation updated, but there's some build error. I can't see it now,
the page is blocked at Cardiff University

--
Ticket URL: <https://code.djangoproject.com/ticket/24230#comment:4>

Django

unread,
Jun 2, 2015, 4:05:49 PM6/2/15
to django-...@googlegroups.com
#24230: Add language name translated into active language to LANG_INFO dictionary
-------------------------------------+-------------------------------------
Reporter: tricoder42 | Owner:
| tricoder42
Type: New feature | Status: closed
Component: | Version: master
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: filter tag | Triage Stage: Accepted
translated language lang_code |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"002b3d87b5f1e35edcb6e14ce2e2827fc6c032a1" 002b3d8]:
{{{
#!CommitTicketReference repository=""
revision="002b3d87b5f1e35edcb6e14ce2e2827fc6c032a1"
Fixed #24230 -- Added translated language name for i18n template
tag/filter.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24230#comment:5>

Reply all
Reply to author
Forward
0 new messages