Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13973 closed (duplicate)

Get current language name filter in templates

Reported by: Secator <mariusz.jamro@…> Owned by: nobody
Component: Translations Version: 1.2
Severity: Keywords: language name
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently there's no way to retrieve current language name easily in templates. You can only use {% get_current_language ... %} filter to get the language code (eg. 'en-us' or 'de-de').
There should be a template filter in django.templatetags.i18n to get the "English" or "German" strings (verbose name of the language).

Example:

#settings.py:
LANGUAGES = (
  ('de', 'German'),
  ('en', 'English'),
)

#templates:
{% get_current_language as LANGUAGE_CODE %} # Existing filter. Returns en-us if language is english.
{% get_current_language_name as LANGUAGE_NAME %} # Proposed filter. Should return 'English' if LANGUAGE_CODE is 'en'. Basically should return the second element of settings.LANGUAGES touples.

Change History (2)

comment:1 Changed 5 years ago by ramiro

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

This is part of what has been proposed and discussed on #4030.

That ticket has been accepted by two core developers and has a patch that contains documentation and test (although it could be outdated, perhaps we could revive it and propose for 1.3). For that reason I'm closing this ticket as duplicate.

comment:2 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top