pallets-eco / flask-security

Quick and simple security for Flask applications
MIT License
1.63k stars 513 forks source link

help wanted, login error messages not translated #801

Open monsurvey1 opened 5 years ago

monsurvey1 commented 5 years ago

Hi, I use the flask-security and flask-babelex, tried to make a multi language website, everything is working fine, login page is translated, my problem is the error messages never translated in the next request, I should reload the complete app so that it will be translated, and once it is translated for example in French, it can not return to English if I switch the language in the next request, other text is translated very well except the error messages.

I want a solution please.

image

jwag956 commented 5 years ago

So I think the issue is that ?lang=fr is not an accepted way to transmit language preference - what happens is when you actually hit 'submit' THAT POST request has as an Accept-Language header whatever your browser default it. Are you using Flask-Admin that recommends setting "lang" in the session?

When I set up a different browser and changed default language - things seemed to work better: Screen Shot 2019-06-21 at 10 02 17 PM

jwag956 commented 5 years ago

After writing some additional tests - I reproduced your scenario. This is related to another problem concerning form labels. In both cases, messages were being bound to translations to early.

Both these issues have been fixed in: https://pypi.org/project/Flask-Security-Too/#history