Hi,

based on the ideas of Jacob and Robert and based on the discussion on
IRC tonight, I propose the following changes to the i18n branch:

The form {{ _('....') }} and the {% i18n ... %} tag will go. As will
the python string interpolation in translation strings. They will be
replaced by the following:

{% trans "...." %}

This is inline translation, much linke {{ _('...') }} before.

{% trans "...." noop %}

This will be the gettext_noop variant of the i18n tag. It will mark a
string for translation, but don't actually do any translation.

{% blocktrans %} ... {{ variable }} ... {% endblocktrans %}

This will translate a block of text with paramters. The blocktrans tag
will have several limitations:

- you can't have any other block tags within it
- you can only use variable names in {{ }}, no strings and no filters

The restrictions are necessary to have a working projection from the
django template stuff to gettext semantics - with the above
restrictions in place it's simple to have a "template massager" that
turns a template into something that is understood by xgettext and so
can be easily turned into .po files.

If you need filtered expressions, you need to bind them to local
variables for the block:

{% blocktrans with variable|filter as newvar %}
 ... {{ newvar }} ...
{% endblocktrans %}

The plural form (ngettext) will be based on that:

{% blocktrans count list|count as counter with var|filter as newvar %}
This is only one {{ newvar }} object
{% plural %}
These are {{ counter }} {{ newvar }} objects
{% endblocktrans %}

There one problem left: filters use the _() syntax for their parameter
string (for example yesno is a candidate for a translated parameter) to
mark their parameter string for translation. I think in those cases the
_() syntax has to stay - at least I don't know any other syntax that
would be more "django" in that situation.

If there are no strong objects, I will start with implementing that
stuff quite soon. People already using the i18n branch will have to
switch to the new syntax for their own templates, because the
make-messages.py needs to switch it's "template massager" to the new
syntax and so won't support the old syntax any more. And I will remove
the old stuff from the i18n branch. It _is_ a branch, after all, so
some change was to be expected ;-)

I will change all admin templates to the new syntax, of course, so that
we can see the new stuff in action again.

bye, Georg

Reply via email to