Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11142 closed (invalid)

internalization of forms bug

Reported by: davidarakelian Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: Forms, fields, labels, internalization
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I am trying to translate my website to french version and I don't know if this is bug or wrong way of doing.

When I visit the website with french browser (locales fr), I can see all the translations properly apart from the Form Fields.

I have the following

# User login form
class UserLoginForm(forms.Form):
    login = forms.EmailField(label=_('Login'), max_length=150)
    password = forms.CharField(label=_('Password'), widget=forms.PasswordInput)

I translated and compiled the label for Login and Password to french.

this is my

# Language code for this installation. All choices can be found here:

#gettext = lambda s: s
    ('en', 'English'),
    ('fr', 'French'),
    ('tr', 'Turkish'),    

If I change this to :


My form fields are translated as well. But my default language is now french.
I just want to have english as default and French depending on locales etc...

Change History (4)

comment:1 Changed 9 years ago by Alex Gaynor

What _ did you import in your forms file?

comment:2 Changed 9 years ago by davidarakelian

from django.utils.translation import ugettext as _

this is what I imported to use the _()

comment:3 Changed 9 years ago by Alex Gaynor

Resolution: invalid
Status: newclosed

You need to use ugettext_lazy since it's a module level string.

comment:4 Changed 9 years ago by davidarakelian

That worked like a charm, thank you!

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