Babel is still broken.

This commit is contained in:
David Bryan 2019-10-28 23:35:13 +00:00
parent bad1c663ab
commit 59778d4124
3 changed files with 23 additions and 9 deletions

3
babel.cfg Normal file
View file

@ -0,0 +1,3 @@
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_

9
config.py Normal file
View file

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
# ...
# available languages
LANGUAGES = {
'en': 'English',
'de': 'German',
'ja': 'Japanese',
'es': 'Español'
}

View file

@ -74,20 +74,24 @@ if(True):
#Set up the Database for storing cards #Set up the Database for storing cards
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + db_file app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + db_file
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['BABEL_DEFAULT_LOCALE'] = 'de'
db = SQLAlchemy(app) db = SQLAlchemy(app)
app.config['BABEL_DEFAULT_LOCALE'] = "de"
app.config['BABEL_DEFAULT_TIMEZONE'] = "UTC"
babel = Babel(app) babel = Babel(app)
#from app import views
@babel.localeselector #@babel.localeselector
def get_locale(): #def get_locale():
# Basic method, can be used as a fallback if a user's profile does not specify a language, # Basic method, can be used as a fallback if a user's profile does not specify a language,
# or a user hasn't yet registered. # or a user hasn't yet registered.
result = request.accept_languages.best_match(LANGUAGES.keys()) #user = getattr(g, 'user', None)
#if user is not None:
#return user.locale
#return request.accept_languages.best_match(LANGUAGES.keys())
# will return language code (en/es/etc). # will return language code (en/es/etc).
return 'es' # return 'es'
return result # return result
# Database Classes # Database Classes
class card_tbl(db.Model): class card_tbl(db.Model):
@ -232,8 +236,6 @@ if(True):
@app.route('/card/<card_id>') @app.route('/card/<card_id>')
def card_mod(card_id): def card_mod(card_id):
#card_id = request.args.get('card_id')
#del_card_id = card_tbl.query.filter_by(card_id=card_id).all()
delCard = card_tbl.query.filter_by(id=card_id).first() delCard = card_tbl.query.filter_by(id=card_id).first()
db.session.delete(delCard) db.session.delete(delCard)
db.session.commit() db.session.commit()