Hi, I translate all static content with no problem. But how can I translate the forms that are shown in the template?
In template I use: {% trans ‘Example’ %}
How can I use ‘trans’ in forms?
Thanks!
Forms.py
class LoginForm(forms.ModelForm):
username = forms.CharField(label='User')
password = forms.CharField(label='Password')
class Meta:
model = User
fields = ('username', 'password')
def __init__(self,*args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs.update({'class': 'form-control'})
self.fields['username'].label = "User"
self.fields['password'].widget.attrs.update({'class': 'form-control','type':'password'})
self.fields['password'].label = "Password"
Settings.py
LANGUAGE_CODE = 'EU'
ugettext = lambda s: s
LANGUAGES = (
('EN', '{}'.format(ugettext('EN'))),
('ES', '{}'.format(ugettext('ES'))),
('EU', '{}'.format(ugettext('EU'))),
('FR', '{}'.format(ugettext('FR'))),
)
TIME_ZONE = 'Europe/Madrid'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (
os.path.join(BASE_DIR, "locale"),
)