2
我開發了多語言網站。 網頁有URI是這樣的:如何傳遞給url_for默認參數?
/RU/about
/EN/about
/IT/about
/JP/about
/EN/contacts
和Jinja2的模板,我寫:
<a href="{{ url_for('about', lang_code=g.current_lang) }}">About</a>
我必須寫LANG_CODE = g.current_lang所有url_for
電話。
是否可以隱含地通過lang_code=g.current_lang
到url_for
?而只寫{{ url_for('about') }}
我的路由器是這樣的:
@app.route('/<lang_code>/about/')
def about():
...