我开发多语言网站。页面有这样的 URI:
/RU/about
/EN/about
/IT/about
/JP/about
/EN/contacts
在 jinja2 模板中我写:
<a href="{{ url_for('about', lang_code=g.current_lang) }}">About</a>
我必须在所有url_for
调用中编写 lang_code=g.current_lang 。
是否可以隐式传递lang_code=g.current_lang
给?url_for
并且只写 {{ url_for('about') }}
我的路由器看起来像:
@app.route('/<lang_code>/about/')
def about():
...