Opened 13 years ago
Closed 13 years ago
#17621 closed Bug (worksforme)
django.utils.translation.activate() issue
Reported by: | 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)
follow-up: 2 comment:1 by , 13 years ago
comment:2 by , 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 , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This is exactly the reason why ugettext_lazy
exists :)
https://docs.djangoproject.com/en/dev/topics/i18n/translation/#lazy-translation
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?