From bad1c663ab73c9fc0d62ca0e5ee2c191136d2773 Mon Sep 17 00:00:00 2001 From: David Bryan Date: Mon, 28 Oct 2019 23:15:54 +0000 Subject: [PATCH] Babel is just not working. --- install-all.sh | 1 + proxmark3-web.py | 17 +++++++++++++++++ templates/cards.html | 16 ++++++++-------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/install-all.sh b/install-all.sh index 06b0735..14d6806 100755 --- a/install-all.sh +++ b/install-all.sh @@ -6,6 +6,7 @@ sudo apt-get update && sudo apt-get -y install --no-install-recommends git ca-ce libreadline-dev gcc-arm-none-eabi libnewlib-dev python3-flask python3-flask-sqlalchemy hostapd python3-pip python3-dateutil python3-dateparser libev-dev gunicorn3 && \ sudo pip3 install --upgrade pip && \ sudo pip3 install datetime && \ +sudo pip3 install Flask-Babel && \ cd ~ && git clone https://github.com/RfidResearchGroup/proxmark3.git &&\ cd ~/proxmark3/ && git pull && make clean && make all && sudo make install &&\ cd ~/proxmark3-web && \ diff --git a/proxmark3-web.py b/proxmark3-web.py index ab5530e..dec8fd3 100755 --- a/proxmark3-web.py +++ b/proxmark3-web.py @@ -7,7 +7,10 @@ import os, string, subprocess, sys, time, random from flask import Flask, flash, redirect, render_template, \ request, url_for from flask_sqlalchemy import SQLAlchemy +from flask_babel import Babel +from flask_babel import gettext, ngettext from datetime import datetime +from config import LANGUAGES debug=1 @@ -65,12 +68,26 @@ while not serial_port: time.sleep(delay) if(True): + # create and configure the app app = Flask(__name__, instance_relative_config=True) #Set up the Database for storing cards app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + db_file app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + app.config['BABEL_DEFAULT_LOCALE'] = 'de' db = SQLAlchemy(app) + babel = Babel(app) + #from app import views + + @babel.localeselector + def get_locale(): + # 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. + result = request.accept_languages.best_match(LANGUAGES.keys()) + + # will return language code (en/es/etc). + return 'es' + return result # Database Classes class card_tbl(db.Model): diff --git a/templates/cards.html b/templates/cards.html index 65eceb7..fbfb654 100644 --- a/templates/cards.html +++ b/templates/cards.html @@ -24,19 +24,19 @@
- Action: + {{ gettext('Action:') }}
- Facility Code: + {{ gettext('Facility Code:') }}
- Card Number: + {{ gettext('Card Number:') }}
- Raw HID Formated Card: + {{ gettext('Card Raw') }}
- OEM Code: + {{ gettext('OEM Code:') }}
{% for row in card %} @@ -44,15 +44,15 @@
- +
- +
- +