Closed bekab95 closed 4 years ago
You can always write:
@babel.localeselector
def get_locale():
return request.url.split('/', 2)[1]
I want to make url_prefix logic correctly https://stackoverflow.com/questions/49496761/two-language-flask-site-with-or-without-blueprints this is my example works without babel but I think there is cleaner solution for multiple lang prefixes with cookie and babel
Use {% trans %}
tags in templates http://jinja.pocoo.org/docs/2.10/templates/#i18n
Do the setup https://pythonhosted.org/Flask-Babel/#flask.ext.babel.Babel Remember to do the "Translating Applications" part also.
You probably want a locale selector like:
@babel.localeselector
def get_locale():
return getattr(g, 'lang_code', None)
I will try but if you have a working example please refer
I will try but if you have a working example please refer
I cannot share any of the ones I have worked on, but at the end of this blog, there is a working example of application with i18n.
I have seen many examples but it was tricky for me to get fully clean solution for translating..
My main question was the function how to switch between Lang s
With Flask Can I change translations with url prefix ? for example mysite.com/en and mysite.com/ka