Opened 13 years ago

Closed 13 years ago

#17621 closed Bug (worksforme)

django.utils.translation.activate() issue

Reported by: tomasz.zawadzinski@… Owned by: nobody
Component: Internationalization Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.utils.translation.activate() doesn't affect on form instances. Strings defined in a class of form (ex label, error_messages etc), are translated only in a result of setting a proper cookie or session key.

Change History (3)

comment:1 by Claude Paroz, 13 years ago

Please provide us with real code so as we can judge if the problem is in Django or on your side. Did you use ugettext_lazy to mark form class strings for translation?

in reply to:  1 comment:2 by anonymous, 13 years ago

I'm sorry, everything is fine using ugettext_lazy. I don't know if this problem is worth solving anymore.

code looked like this (other strings were translated properly, these in templates and other helping functions):

from django.utils.translation import ugettext as _

class BookingForm(forms.Form):
   name = forms.CharField(max_length=25, label=_(u'Imię'), error_messages={'required': _(u'Proszę wpisać imię.')})
   [...]

def index(request, lang=''):
   if lang == 'en':
      translation.activate('en')
   elif lang == 'pl':
      translation.activate('pl')

   c = {'form': BookingForm()}
   [...]

comment:3 by Aymeric Augustin, 13 years ago

Resolution: worksforme
Status: newclosed

This is exactly the reason why ugettext_lazy exists :)

https://docs.djangoproject.com/en/dev/topics/i18n/translation/#lazy-translation

Note: See TracTickets for help on using tickets.
Back to Top