Thanks Ramiro, that worked.
 I think I understand why, but there's one thing I still don't get. I have 
some error messages that I was marking for translation with  ugettext_noop, 
as I read it was a good way if I wanted for example to log the message 
without translation and translate it only when displaying to the user. They 
appeared in the .po file, translated and compile the messages but I 
couldn't find the way to get them to display in other language either. I 
first thought it was because they were flagged as fuzzy. Removed that, 
recompiled and still no luck. I changed to  ugettext_lazy and they are 
working now too, but for what understand with  ugettext_lazy it will get 
translated when I want to use it, so logging would get screwed. 
What would the correct way to make the noop to work? I went over the 
documentation many times already but I just don't get what I am missing.

Thanks
Marcela

On Thursday, October 30, 2014 8:45:32 PM UTC-3, Marcela Campo wrote:
>
> Hi,
>   I am using the translation functionality in Django 1.7 successfully for 
> plain strings in a template, so something simple like
>
> {% trans "Edit Client" %} 
>
> works just fine.
>
>
> I am now trying to translate success_message from views with the 
> SuccessMessageMixin and also error messages that bubble up from business 
> logic but I just can't make those work.The messages show up for translation 
> in the .po file. For example:
>
> # python-format
> #: views/adminDashboard.py:158
> #, python-format
> msgid "Productive Unit %(name)s has been created."
> msgstr "La Unidad Productiva %(name)s ha sido creada."
>
> I have compiled the messages already.
>
> In my view
>
> ....
> ....
> from django.utils.translation import ugettext as _
> class CustomerFieldUpdateView(AdminRequiredMixin, SuccessMessageMixin, 
> UpdateView):
>     model = Field
>     template_name = 'ui/field_update_form.html'
>     success_message = _('Productive Unit %(name)s has been updated.')
> .....
>
> In the template:
> ....
> {% load i18n %}
> ....
> {% if messages %}
>     {% for message in messages %}
>               {{ message }}
>     {% endfor %}
> {% endif %}
> ....
>
>
> If I look at self.request.LANGUAGE_CODE in the view is set to 'es' but 
> still the messages that bubble up from python code are displayed in the 
> default ('en') whereas the plain strings in the template are correctly 
> translated to spanish. I also tried using {% trans message.message %} or 
> blocktrans as well, but nothing works. 
>
> Any ideas what I am missing?
>
> Thanks!!! 
> Marcela
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4aa7add8-1b08-40bf-83f2-5d77202ad42e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to