mirror of
https://github.com/videoman/proxmark3-web.git
synced 2024-09-20 06:46:11 +08:00
Added babel
This commit is contained in:
parent
1ac9abdf0f
commit
d28883ae2c
|
@ -1,9 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# ...
|
||||
# available languages
|
||||
LANGUAGES = {
|
||||
'en': 'English',
|
||||
'de': 'German',
|
||||
'ja': 'Japanese',
|
||||
'es': 'Español'
|
||||
}
|
4
mysettings.cfg
Normal file
4
mysettings.cfg
Normal file
|
@ -0,0 +1,4 @@
|
|||
BABEL_DEFAULT_LOCALE = 'en'
|
||||
BABEL_DEFAULT_TIMEZONE = 'UTC'
|
||||
BABEL_TRANSLATION_DIRECTORIES = '/home/pi/proxmark3-web/translations'
|
||||
|
|
@ -6,11 +6,11 @@ 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 flask_babel import Babel
|
||||
from flask_babel import force_locale as babel_force_locale
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from datetime import datetime
|
||||
from config import LANGUAGES
|
||||
|
||||
debug=1
|
||||
|
||||
|
@ -71,27 +71,18 @@ if(True):
|
|||
|
||||
# create and configure the app
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
app.config.from_pyfile('/home/pi/proxmark3-web/mysettings.cfg')
|
||||
babel = Babel(app)
|
||||
babel.init_app(app)
|
||||
#Set up the Database for storing cards
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + db_file
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
db = SQLAlchemy(app)
|
||||
app.config['BABEL_DEFAULT_LOCALE'] = "de"
|
||||
app.config['BABEL_DEFAULT_TIMEZONE'] = "UTC"
|
||||
babel = Babel(app)
|
||||
|
||||
#@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.
|
||||
#user = getattr(g, 'user', None)
|
||||
#if user is not None:
|
||||
#return user.locale
|
||||
@babel.localeselector
|
||||
def get_locale():
|
||||
return request.accept_languages.best_match(['ko','zh','ja', 'ja_JP', 'en'])
|
||||
|
||||
#return 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):
|
||||
|
@ -106,8 +97,6 @@ if(True):
|
|||
|
||||
def __repr__(self):
|
||||
return '<card_raw {}>'.format(self.card_raw)
|
||||
# return "<id(id='%s', time_stamp='%s', card_raw='%s', card_format='%s', card_oem='%s', card_facility_code='%s')>" % (
|
||||
# self.id, self.time_stamp, self.card_raw, self.card_number, self.card_format, self.card_oem, self.card_facility_code)
|
||||
|
||||
app.config.from_mapping(
|
||||
SECRET_KEY=str(random.getrandbits(64))
|
||||
|
@ -174,7 +163,7 @@ if(True):
|
|||
card_read=card_read
|
||||
)
|
||||
else:
|
||||
flash('ERROR: Could not read a card... please try again....')
|
||||
flash(gettext('ERROR: Could not read a card... please try again....'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/hid/sim')
|
||||
|
@ -187,7 +176,7 @@ if(True):
|
|||
#write_hid = subprocess.run([proxmark3_rdv4_client, serial_port, '-c', 'lf hid sim ' + raw_cardnumber, '&' ], capture_output=True)
|
||||
write_hid = subprocess.Popen([proxmark3_rdv4_client, serial_port, '-c', 'lf hid sim ' + raw_cardnumber ])
|
||||
|
||||
flash('Simulate Mode has been entered, please press the button on the PM3 to exit...')
|
||||
flash(gettext('Simulate Mode has been entered, please press the button on the PM3 to exit...'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
#if('Simulating HID tag with ID' in write_hid.stdout.decode('ASCII')):
|
||||
|
@ -215,7 +204,7 @@ if(True):
|
|||
flash('Wrote ID to card.')
|
||||
return redirect(url_for('index'))
|
||||
else:
|
||||
flash('ERROR: CARD DID NOT PROGRAM... TRY AGIAN.')
|
||||
flash(gettext('ERROR: CARD DID NOT PROGRAM... TRY AGIAN.'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/card/list')
|
||||
|
@ -229,7 +218,7 @@ if(True):
|
|||
@app.route('/shutdown')
|
||||
def shutdown_os_now():
|
||||
subprocess.run(['sudo', '/sbin/shutdown', '-P'])
|
||||
flash('System shutdown in progress....')
|
||||
flash(gettext('System shutdown in progress....'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
return render_template('cards.html', card = card)
|
||||
|
@ -241,7 +230,7 @@ if(True):
|
|||
db.session.commit()
|
||||
|
||||
if debug: print('Deleted card id: '+ str(card_id))
|
||||
flash('Card '+card_id+' was deleted from the database...')
|
||||
flash(gettext('Card ') +card_id+ gettext(' was deleted from the database...'))
|
||||
return redirect(url_for('card_list'))
|
||||
|
||||
@app.route('/wipe_card')
|
||||
|
@ -252,7 +241,7 @@ if(True):
|
|||
return redirect(url_for('index'))
|
||||
|
||||
if(wipe_card.returncode == 0):
|
||||
flash('t5577 card wipe complete')
|
||||
flash(gettext('t5577 card wipe complete'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/provision_card')
|
||||
|
@ -266,10 +255,10 @@ if(True):
|
|||
|
||||
if(new_hid_id.returncode == 0):
|
||||
if('HID Prox TAG ID: 1029a0f4d2' in new_hid_id.stdout.decode('ASCII')):
|
||||
flash('Wrote default ID to card.')
|
||||
flash(gettext('Wrote default ID to card.'))
|
||||
return redirect(url_for('index'))
|
||||
else:
|
||||
flash('ERROR: CARD DID NOT PROGRAM... TRY AGIAN.')
|
||||
flash(gettext('ERROR: CARD DID NOT PROGRAM... TRY AGIAN.'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ WorkingDirectory=/home/pi/proxmark3-web/
|
|||
#Type=simple
|
||||
Environment=FLASK_CONFIG=production
|
||||
Environment=FLASK_APP=/home/pi/proxmark3-web/proxmark3-web.py
|
||||
ExecStart=/usr/bin/gunicorn3 --reload proxmark3-web:app -b:8080
|
||||
ExecStart=/usr/bin/gunicorn3 --threads 4 --reload proxmark3-web:app -b:8080
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
|
|
|
@ -8,25 +8,25 @@
|
|||
|
||||
<div class="col">
|
||||
<a href="/provision_card">
|
||||
<button type="button" class="btn btn-primary">CREATE X-Force Red Card</button>
|
||||
<button type="button" class="btn btn-primary">{{ gettext('CREATE X-Force Red Card') }}</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col text-center">
|
||||
<a href="/wipe_card">
|
||||
<button type="submit" class="btn btn-danger" formaction="/wipe_card">Wipe Card</button>
|
||||
<button type="submit" class="btn btn-danger" formaction="/wipe_card">{{ gettext('Wipe Card') }}</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col text-right">
|
||||
<a href="/" >
|
||||
<button type="submit" class="btn btn-warning" formaction="/">RESET</button>
|
||||
<button type="submit" class="btn btn-warning" formaction="/">{{ gettext('RESET') }}</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col text-center">
|
||||
<a href="/shutdown">
|
||||
<button type="submit" class="btn btn-danger" formaction="/shutdown">Shutdown Pi</button>
|
||||
<button type="submit" class="btn btn-danger" formaction="/shutdown">{{ gettext('Shutdown Pi') }}</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<p>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
Status:
|
||||
{{ gettext('Status') }}:
|
||||
{% for message in messages %}
|
||||
{{ message }}
|
||||
{% endfor %}
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<body class="bg-dark">
|
||||
{% include "nav.html" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 py-2">
|
||||
<div class="col-sm-6 py-2">
|
||||
<img class="img-fluid" src="/static/images/X-Force_Red_Logo_For_Dark_Backgrounds.png">
|
||||
</div>
|
||||
<div class="col-sm-6"> </div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 offset-sm-3 py-2">
|
||||
<a href="/read/hid" class="btn btn-danger btn-lg btn-block" role="button">Read HID Card</a>
|
||||
<a href="/read/hid" class="btn btn-danger btn-lg btn-block" role="button">{{ gettext('Read HID Card') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
|||
<div class="col text-white">
|
||||
<h1 class="h4">Card Info</h1>
|
||||
<p>
|
||||
OEM Code: {{ oem }}<br>
|
||||
Facility Code: {{ facility_code }}<br>
|
||||
Card Number: {{ card_number }}<br>
|
||||
Raw HID Formated Card: {{ raw_cardnumber }}
|
||||
{{ gettext('OEM Code') }}: {{ oem }}<br>
|
||||
{{ gettext('Facility Code') }}: {{ facility_code }}<br>
|
||||
{{ gettext('Card Number') }}: {{ card_number }}<br>
|
||||
{{ gettext('Raw HID Formated Card') }}: {{ raw_cardnumber }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -29,11 +29,11 @@
|
|||
<label class="sr-only" for="exampleInputAmount">Card to clone</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Card ID: </span>
|
||||
<span class="input-group-text">{{ gettext('Card ID') }}: </span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="raw_cardnumber" value={{raw_cardnumber if raw_cardnumber else '2006540A73'}} placeholder={{raw_cardnumber if raw_cardnumber else '2006540A73'}}>
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-danger" id="button-addon2">Clone Card!</button>
|
||||
<button type="submit" class="btn btn-danger" id="button-addon2">{{ gettext('Clone Card') }}!</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,7 +46,7 @@
|
|||
<p>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
Status:
|
||||
{{ gettext('Status') }}:
|
||||
{% for message in messages %}
|
||||
{{ message }}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<nav class="navbar navbar-dark" style="background-color: #ad1700;">
|
||||
<a class="navbar-brand" href="#">Proxmark3-web</a>
|
||||
<a class="navbar-brand" href="#">{{ gettext('Proxmark3-web') }}</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
@ -7,10 +7,10 @@
|
|||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="/">Read Card<span class="sr-only">(current)</span></a>
|
||||
<a class="nav-link" href="/">{{ gettext('Read Card') }}<span class="sr-only">(current)</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/card/list">Captured Cards</a>
|
||||
<a class="nav-link" href="/card/list">{{ gettext('Captured Cards') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2019-10-28 22:12+0000\n"
|
||||
"PO-Revision-Date: 2019-10-28 22:12+0000\n"
|
||||
"POT-Creation-Date: 2019-10-31 08:44+0000\n"
|
||||
"PO-Revision-Date: 2019-10-31 08:45+0000\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: de\n"
|
||||
"Language-Team: de <LL@li.org>\n"
|
||||
|
@ -18,35 +18,89 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.7.0\n"
|
||||
|
||||
#: app.py:166 proxmark3-web.py:166
|
||||
msgid "ERROR: Could not read a card... please try again...."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:179 proxmark3-web.py:179
|
||||
msgid ""
|
||||
"Simulate Mode has been entered, please press the button on the PM3 to "
|
||||
"exit..."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:207 app.py:261 proxmark3-web.py:207 proxmark3-web.py:261
|
||||
msgid "ERROR: CARD DID NOT PROGRAM... TRY AGIAN."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:221 proxmark3-web.py:221
|
||||
msgid "System shutdown in progress...."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:233 proxmark3-web.py:233
|
||||
msgid "Card "
|
||||
msgstr ""
|
||||
|
||||
#: app.py:233 proxmark3-web.py:233
|
||||
msgid " was deleted from the database..."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:244 proxmark3-web.py:244
|
||||
msgid "t5577 card wipe complete"
|
||||
msgstr ""
|
||||
|
||||
#: app.py:258 proxmark3-web.py:258
|
||||
msgid "Wrote default ID to card."
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:11
|
||||
msgid "CREATE X-Force Red Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:17
|
||||
msgid "Wipe Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:23
|
||||
msgid "RESET"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:29
|
||||
msgid "Shutdown Pi"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:27
|
||||
msgid "Vorgang:"
|
||||
msgid "Action:"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:30
|
||||
msgid "Einrichtungscode:"
|
||||
msgid "Facility Code:"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:33
|
||||
msgid "Kartennummer:"
|
||||
msgid "Card Number:"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:36
|
||||
msgid "Rohdaten:"
|
||||
msgid "Card Raw"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:39
|
||||
msgid "OEM-Code:"
|
||||
msgid "OEM Code:"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:47
|
||||
msgid "Klonnummer"
|
||||
msgid "Clone"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:51
|
||||
msgid "Wiederholung"
|
||||
msgid "Simulate"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:55
|
||||
msgid "löschen"
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:9
|
||||
msgid "Read HID Card"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2019-10-28 22:12+0000\n"
|
||||
"PO-Revision-Date: 2019-10-28 22:13+0000\n"
|
||||
"POT-Creation-Date: 2019-10-31 10:35+0000\n"
|
||||
"PO-Revision-Date: 2019-10-31 10:38+0000\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: ja\n"
|
||||
"Language-Team: ja <LL@li.org>\n"
|
||||
|
@ -18,6 +18,60 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.7.0\n"
|
||||
|
||||
#: app.py:166 proxmark3-web.py:166
|
||||
msgid "ERROR: Could not read a card... please try again...."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:179 proxmark3-web.py:179
|
||||
msgid ""
|
||||
"Simulate Mode has been entered, please press the button on the PM3 to "
|
||||
"exit..."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:207 app.py:261 proxmark3-web.py:207 proxmark3-web.py:261
|
||||
msgid "ERROR: CARD DID NOT PROGRAM... TRY AGIAN."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:221 proxmark3-web.py:221
|
||||
msgid "System shutdown in progress...."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:233 proxmark3-web.py:233
|
||||
msgid "Card "
|
||||
msgstr ""
|
||||
|
||||
#: app.py:233 proxmark3-web.py:233
|
||||
msgid " was deleted from the database..."
|
||||
msgstr ""
|
||||
|
||||
#: app.py:244 proxmark3-web.py:244
|
||||
msgid "t5577 card wipe complete"
|
||||
msgstr ""
|
||||
|
||||
#: app.py:258 proxmark3-web.py:258
|
||||
msgid "Wrote default ID to card."
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:11
|
||||
msgid "CREATE X-Force Red Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:17
|
||||
msgid "Wipe Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:23
|
||||
msgid "RESET"
|
||||
msgstr ""
|
||||
|
||||
#: templates/buttons.html:29
|
||||
msgid "Shutdown Pi"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:13 templates/main.html:49
|
||||
msgid "Status"
|
||||
msgstr ""
|
||||
|
||||
#: templates/cards.html:27
|
||||
msgid "Action:"
|
||||
msgstr ""
|
||||
|
@ -50,3 +104,43 @@ msgstr ""
|
|||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:9
|
||||
msgid "Read HID Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:17
|
||||
msgid "OEM Code"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:18
|
||||
msgid "Facility Code"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:19
|
||||
msgid "Card Number"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:20
|
||||
msgid "Raw HID Formated Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:32
|
||||
msgid "Card ID"
|
||||
msgstr ""
|
||||
|
||||
#: templates/main.html:36
|
||||
msgid "Clone Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/nav.html:2
|
||||
msgid "Proxmark3-web"
|
||||
msgstr ""
|
||||
|
||||
#: templates/nav.html:10
|
||||
msgid "Read Card"
|
||||
msgstr ""
|
||||
|
||||
#: templates/nav.html:13
|
||||
msgid "Captured Cards"
|
||||
msgstr ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue