I've been struggling with this for a while now... Calling for help.. I
believe I'm doing something stupid :
here is a view :
def display_vak_teacher(request,**kwargs):
(.... skip skip skip)
slogan=ugettext_lazy("Welcome to the page of the %(subj)s class
of %(fn)s %(ln)s" % {
'subj':vak_per_teacher.vak.name.lower(),
'fn':vak_per_teacher.teacher.first_name,
'ln':vak_per_teacher.teacher.last_name})
return render_to_response(template, {
(some more stuff)
'slogan' : slogan,
(some more stuff again)
})
and a django.po file that looks like (for that string):
#: content/views.py:362
#, python-format
msgid "Welcome to the page of the %(subj)s class of %(fn)s %(ln)s"
msgstr "Welkom op de pagina van de klas %(subj)s van %(fn)s %(ln)s"
It apparently never gets translated. What am I doing wrong?
All strings with no variables included are translated all right, but
all the ones with a variable are not.
I must be missing something very obvious but I can't find what...
any idea?
Francois
2009/7/2 François Verbeek <fran...@verbeek.name>:
> Mmm to make the problem easier to deal with I wrote a very very small
> app with just 1 view and a very basic template :
> from django.http import HttpResponse
> from django.utils.translation import ugettext as _
> from django.shortcuts import render_to_response,get_object_or_404
> def display_a_string_through_template(request,**kwargs):
> data=kwargs.get("argument","nothing")
> string=_("Hi, there %(wee)s" % {'wee':data})
This should be _("Hi, there %(wee)s") % {'wee': data}
Note the placement of parentheses. gettext recognizes only the string
"Hi, there %(wee)s" before interpolation, and not anymore when the
content of 'wee' has been filled in.
Matthias
Use:
_("Hi, there %(wee)s") % {'wee':data}
--
Kind Regards