Opened 18 years ago

Closed 18 years ago

Last modified 8 years ago

#1193 closed enhancement (invalid)

Write {% load i18n %} only once

Reported by: inerte@… Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: minor Keywords: i18n, trans
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If you use {% trans "string" %}, {% load i18n %} must exists on the same template file.

What I want to do is to put {% load i18n %} only once on my "base" template and use {% trans "string" %} on every "children" template, since translations are usually necessary for the whole website.

Error condition:


{% load i18n %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


{% extends "base" %}
{% trans "hellow world" %}

It shows a Invalid block tag: 'trans' error...

Change History (7)

comment:1 Changed 18 years ago by jim-django@…

My understanding is that this is a feature, not a bug. The template system only provides the tags loaded in each template file itself so that templates can be reused without having to guess at what their environment expectations are.

A fix for the problem of having to put {% load i18n %} in every template might be to add an app-specific automatically loaded template setting, so each app author can decide what the base namespace for their templates is. This would require adding an app-specific configuration system, and somehow letting the template module know what the 'current app' is.

comment:2 Changed 18 years ago by hugo

Component: InternationalizationTemplate system
Owner: changed from hugo to Adrian Holovaty

As jim says, this is a feature of the template system: you need to load the taglibs to use in every template that uses the taglib. The idea of a setting to define "default taglibs" on the other hand is something that might be useful - so I reassign it to the template system, so Adrian can comment.

comment:3 Changed 18 years ago by Adrian Holovaty

Resolution: invalid
Status: newclosed

This is a feature of the template system.

comment:4 Changed 11 years ago by anonymous

Easy pickings: unset
UI/UX: unset

I don't understand, so how would I add {% load i18n %} to the default taglibs?

What is the feature of the template system called?

comment:5 Changed 11 years ago by Stefano Crosta <stefano@…>

for reference (eg. anonymous question) this is how to always load a tag

comment:6 in reply to:  5 Changed 11 years ago by anonymous

Replying to Stefano Crosta <stefano@…>:

for reference (eg. anonymous question) this is how to always load a tag

It fails on add_to_builtins('django.contrib.staticfiles.templatetags.staticfiles')

ImproperlyConfigured: The SECRET_KEY setting must not be empty.

comment:7 Changed 8 years ago by Ciro Santilli 六四事件 法轮功 包卓轩


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