M
M
mortefy2018-12-04 23:29:51
Python
mortefy, 2018-12-04 23:29:51

How to organize a multilingual site on FLASK like site.com/en/ site.com/ru/?

Subject.
I use Flask+babel but I don't like how it gets indexed by search engines.
I would like to separate sites of different translations.
Or maybe someone will tell you how to do it so that everything is top type with search engines, and change the site language by ?lang=ru
How to do it right? =)
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pcdesign, 2018-12-05
@mortefy

Can be put in before_request

@app.before_request
    def before_request():
        lang = request.args.get('lang')

And then slip this lang into Flask + babel, you can also automatically get the user's language.
If blueprint is used, then so
app.register_blueprint(main, url_prefix='main/<lang>/')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question