jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
797 stars 135 forks source link

FormWizard does not support internationalization of named wizard steps #135

Closed lulumuts closed 3 years ago

lulumuts commented 5 years ago

Hi all, I'm trying to translate my django app, and all aspects work except for the formtools wizard, specifically the strings assigned to my multistep forms. In Urls.py I have:

named_formwizardforms = ( (('Your Details'), FormStepOne), (('Residence Preference'), FormStepTwo), (('Immigration & Schooling'), FormStepThree), (('Mobility Expenses'), FormStepFour), (('Living Expenses'), FormStepFive), ) urlpatterns = [ path(_('form/'), FormWizardView.as_view(named_formwizard_forms),name="form"), ] When I makemessages, the strings show up in my django.po, and while i have translated them to french, they either do not compile or there is some format I am missing in the template. Please advise.

Thanks

claudep commented 5 years ago

Shouldn't your strings be _('Your Details') instead of ('Your Details')?

lulumuts commented 5 years ago

Hi my mistake, this is the way the code actually looks, can't say why it copied without the underscore.

named_formwizardforms = ( (('Your Details'), FormStepOne), (('Residence Preference'), FormStepTwo), (('Immigration & Schooling'), FormStepThree), (('Mobility Expenses'), FormStepFour), (('Living Expenses'), FormStepFive),

) urlpatterns = [ path(('form/'), FormWizardView.as_view(named_formwizard_forms),name="form"), ]

Any idea why it shows up in my .po file but doesnt translate? I suspect formtools only translates from the django formtools LOCALE folder?

claudep commented 5 years ago

Your are aliasing _ to gettext_lazy not gettext, right?

lulumuts commented 5 years ago

yes exactly

claudep commented 5 years ago

In fact, I dont think the form step name is supposed to be translated, as it is forced to a string soon in its processing. It is just a step name that should be used in the code, not a string to be presented to the user. You can probably store user-visible strings inside the form themselves.