#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.f3369aded533953fa752171f2b31bcf0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.