'placeholder' attrs in forms.TextInput not translated on the fly

123 views
Skip to first unread message

Chang Sun

unread,
Dec 20, 2013, 2:55:35 AM12/20/13
to django...@googlegroups.com
Hi, everyone!

I add placeholder attrs to forms.TextInput so it can show in html5
        widget=forms.TextInput(attrs={'placeholder':
                                      _('Username or Email')}),

However, once I run manage.py runserver and request any web page using one language, then the translation is always translated to this language even when I choose other languages.

Other gettext variables are OK as I choose other languages.
For example:
            self.helper.layout = Layout(
                Field('username_email'),
                Field('password'),
                Submit('submit', _('Sign in')),
            )
_('Sign in') will be translated to different languages on the fly.

Anyone has any ideas about this problem?

I would appreciate any suggestions.

Chang Sun

unread,
Dec 20, 2013, 3:04:51 AM12/20/13
to django...@googlegroups.com
Yeah, I think I have solved this problem myself.
I should use ugettext_lazy here.
Reply all
Reply to author
Forward
0 new messages