Reputation: 9811
I review docs but I am lost... some problem with it:
{% load i18n %}
{% blocktrans %}
{{ wpis.entry.lastChangeDate|timesince }}
{% endblocktrans %}
Raise:
`KeyError: u'wpis.entry.lastChangeDate | timesince'`
Of course, without blocktrans all works fine.
So, what is simples way to translate few words? (I am interesting polish lang, minutes -> minut, hours -> godzin, etc) I will be thankful for clear example.
EDIT: in my .po file i have now:
#: templates/part.html:37
#, python-format
msgid ""
"\n"
"%(lastChangeDate)s\n"
msgstr ""
and i don't see anything about var in docs... now i would do:
msgid "hours"
msgstr "godzin"
etc and bind it to my var (above example don't work...)
Upvotes: 2
Views: 2017
Reputation: 5663
Simply use {{ var|timesince }}
and make sure that in settings.py, LANGUAGE_CODE
is set to your locale and that USE_I18N
is True
.
You don't need to use blocktrans or have custom translations in a .po file for this, it's already included.
Upvotes: 3
Reputation: 1679
{% load i18n %}
{% blocktrans with wpis.entry.lastChangeDate|timesince as lastChangeDate %}
{{ lastChangeDate }}
{% endblocktrans %}
See http://docs.djangoproject.com/en/dev/topics/i18n/#in-template-code for more info.
Upvotes: 3