바블 (플라워 웹 프로젝트를 우분투 16.04/파이썬 2.7.12 사용)로 변환하려고합니다. 테이블을 제외하고 모든 것이 잘 작동하는 것 같습니다. 열의 이름은 번역되지 않습니다. 아무도 내가 그 일을 어떻게하는지 알아?플라스크 바벨 : 플라스크 테이블이 번역되지 않았습니다.
는내 평 예 :
from flask import Flask, render_template
from flask_script import Manager
from flask.ext.babel import Babel, gettext
from flask_table import Table, Col
app = Flask(__name__)
manager = Manager(app)
babel = Babel(app)
class ItemTable(Table):
col1 = Col(gettext('Apple'))
col2 = Col(gettext('Banana'))
col3 = Col(gettext('Pear'))
class Item(object):
def __init__(self, col1, col2, col3):
self.col1 = col1
self.col2 = col2
self.col3 = col3
@babel.localeselector
def get_locale():
return 'de'
@app.route('/')
def index():
items = []
items.append(Item('bla', 'bla', 'bla'))
table = ItemTable(items)
test = gettext("This is a string.")
return render_template('index.html', test=test, table=table)
if __name__ == '__main__':
app.run(debug=True)
그리고 html 파일 : 여기
<h1>{{gettext("Hello World!")}}</h1>
<h2>{{test}}</h2>
{{table}}
가, 난 그냥 독일어로 번역이 작업을 수행하는 경우 테스트, 그래서 get_locale 할 바로 '드'반환 translations 폴더와 babel.cfg가 있고 pybabel extract/init/compile이 작동하면 결과로 나오는 messages.po 파일에 문자열 인 Apple/Banana/Pear가 표시되어 번역됩니다. 그러나 페이지가로드 될 때 "Hello World"와 "test"는 변환되지만 열 문자열은 변환되지 않습니다.
무엇을해야할까요?