2016-09-24 111 views
0

我正在嘗試將國際化添加到我的頁面。比方說,路線/ RU /指數bottle.py模板路徑有什麼問題?

@route('/<path>/<page:re:.*>') 
def callback(path, page): 
    fullpath = ('/%s/%s.html' % (path, page)) 
    print('fullpath %s' % fullpath) 
    return template(fullpath) 

爲什麼沒有它/views/RU/index.html從返回文件模板?

+0

你將有'.html'兩次。 –

+0

@KlausD。對不起,我已經悔改了。當然,路線是/ RU /索引 – pmus

回答

0

只需添加路徑TEMPLATE_PATH

def bottle_monkeypatch(): 
    """ 
    This adds /common folder to bottle template path, thus 
    makes templating cleaner and more manageable. 
    """ 
    from bottle import TEMPLATE_PATH 
    global TEMPLATE_PATH 
    TEMPLATE_PATH.insert(0, './views/common')