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})
      template="renderit.html"
      another_string=_("a second string")
      string2="something"
       
context={'string':string,'astring':another_string,'string2':string2}
      return render_to_response(template,context)


template :

{% load i18n %}
{{string}} <br />
{% trans "Hi, there " %} <br />
{{astring}}<br />
{% blocktrans %}Hi there {{string2}} incl {%endblocktrans%}


  locale/fr/LC_MESSAGES/django.po

#: content/views.py:7 content/views.py:13
#, python-format
msgid "Hi, there %(wee)s"
msgstr " fr trna %(wee)s"

#: content/views.py:8 content/views.py:15
msgid "a second string"
msgstr " senc str fr"

#: content/templates/renderit.html:4
msgid "Hi, there "
msgstr " sdfs sfdf fr"

#: content/templates/renderit.html:6
#, python-format
msgid "Hi there %(string2)s incl "
msgstr "fr ici %(string2)s bla"



And setting.py has LANGUAGE_CODE = 'fr'.

If I use ugettext or ugettext_lazy, I get always the same thing : the  
first string _("Hi, there %(wee)s" % {'wee':data}) is never translated.
{% blocktrans %}Hi there {{string2}} incl {%endblocktrans%} on the  
other hand is translated all right...



On 2 Jul 2009, at 20:05, François Verbeek wrote:

>
> Hi,
>
> 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
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to