french l10n for app
This commit is contained in:
parent
77c72951c7
commit
a3ca5174f3
29
app.py
29
app.py
|
@ -10,14 +10,18 @@ from werkzeug.utils import secure_filename
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
# l10n
|
||||
import gettext
|
||||
LOCALE = os.getenv('LANG', 'en')
|
||||
_ = gettext.translation('template', localedir='locales', languages=[LOCALE]).gettext
|
||||
|
||||
app.config.from_file("defaults.toml", load=toml.load)
|
||||
config_locations = ["./", "~/.", "~/.config/"]
|
||||
for location in config_locations:
|
||||
# Optional config files, ~ is expanded to $HOME on *nix, %USERPROFILE% on windows
|
||||
# ~ app.config.from_file("videopi.toml", load=toml.load, silent=True)
|
||||
if app.config.from_file(os.path.expanduser( location + "pilpil-client.toml"), load=toml.load, silent=True):
|
||||
print("Found configuration file in " + os.path.expanduser( location ))
|
||||
|
||||
print( _("Found configuration file in {}").format( os.path.expanduser(location) ) )
|
||||
|
||||
#UPLOAD_FOLDER = os.path.expanduser('~/Videos')
|
||||
#ALLOWED_EXTENSIONS = {'avi', 'mkv', 'mp4'}
|
||||
|
@ -76,9 +80,6 @@ def led( led_id, state ):
|
|||
|
||||
# Blink the Pi led to allow identification
|
||||
def blinkPy():
|
||||
# disable mmc access led
|
||||
# ~ os.system('echo none | sudo tee /sys/class/leds/led0/trigger')
|
||||
# ~ os.system('echo none | sudo tee /sys/class/leds/led1/trigger')
|
||||
# Blink 10 times
|
||||
for j in range(16):
|
||||
led(0, 1)
|
||||
|
@ -88,8 +89,6 @@ def blinkPy():
|
|||
led(1, 1)
|
||||
time.sleep(.2)
|
||||
# restore default behavior
|
||||
# ~ os.system('echo mmc0 | sudo tee /sys/class/leds/led0/trigger')
|
||||
# ~ os.system('echo default-on | sudo tee /sys/class/leds/led1/trigger')
|
||||
led(0, 0)
|
||||
led(1, 0)
|
||||
return "OK"
|
||||
|
@ -101,7 +100,7 @@ def threadBlink():
|
|||
@app.route("/")
|
||||
@auth.login_required
|
||||
def main():
|
||||
return "Nothing to see here !"
|
||||
return _("Nothing to see here !")
|
||||
|
||||
@app.route("/rssi")
|
||||
@auth.login_required
|
||||
|
@ -112,21 +111,21 @@ def rssi():
|
|||
@auth.login_required
|
||||
def blink():
|
||||
threadBlink()
|
||||
return "Blinkin"
|
||||
return _("Blinkin")
|
||||
|
||||
@app.route("/reboot")
|
||||
@auth.login_required
|
||||
def reboot():
|
||||
stdout = subprocess.run(["sudo", "/usr/sbin/reboot"], capture_output=True)
|
||||
print(stdout)
|
||||
return "Rebooting..."
|
||||
return _("Rebooting...")
|
||||
|
||||
@app.route("/poweroff")
|
||||
@auth.login_required
|
||||
def shutdown():
|
||||
stdout = subprocess.run(["sudo", "/usr/sbin/poweroff"], capture_output=True)
|
||||
print(stdout)
|
||||
return "Shutting down..."
|
||||
return _("Shutting down...")
|
||||
|
||||
# File upload
|
||||
|
||||
|
@ -136,20 +135,20 @@ def upload_file():
|
|||
if request.method == 'POST':
|
||||
# check if the post request has the file part
|
||||
if 'file' not in request.files:
|
||||
return "No file part: " + str(request.files)
|
||||
return _("No file part: {}").format(str(request.files))
|
||||
file = request.files['file']
|
||||
# If the user does not select a file, the browser submits an
|
||||
# empty file without a filename.
|
||||
if file.filename == '':
|
||||
return 'No selected file'
|
||||
return _("No selected file")
|
||||
if file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(UPLOAD_FOLDER, filename))
|
||||
return "File saved in " + UPLOAD_FOLDER
|
||||
return _("File saved in {}").format(UPLOAD_FOLDER)
|
||||
return "OK"
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Turn ACT and POW leds off on start
|
||||
ledSetup()
|
||||
# ~ ledSetup()
|
||||
# app.run()
|
||||
serve(app, host='127.0.0.1', port=5000, url_scheme='https')
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,49 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2022-11-03 12:59+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: ../app.py:25
|
||||
msgid "Found configuration file in {}"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:104
|
||||
msgid "Nothing to see here !"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:115
|
||||
msgid "Blinkin"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:122
|
||||
msgid "Rebooting..."
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:129
|
||||
msgid "Shutting down..."
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:139
|
||||
msgid "No file part: {}"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:144
|
||||
msgid "No selected file"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:148
|
||||
msgid "File saved in {}"
|
||||
msgstr ""
|
||||
|
Binary file not shown.
|
@ -0,0 +1,49 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2022-11-03 12:59+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: French <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: ../app.py:25
|
||||
msgid "Found configuration file in {}"
|
||||
msgstr "Fichier de configuration trouvé dans {}"
|
||||
|
||||
#: ../app.py:104
|
||||
msgid "Nothing to see here !"
|
||||
msgstr "Rien à voir ici!"
|
||||
|
||||
#: ../app.py:115
|
||||
msgid "Blinkin"
|
||||
msgstr "Cligne"
|
||||
|
||||
#: ../app.py:122
|
||||
msgid "Rebooting..."
|
||||
msgstr "Redémarrage..."
|
||||
|
||||
#: ../app.py:129
|
||||
msgid "Shutting down..."
|
||||
msgstr "Extinction"
|
||||
|
||||
#: ../app.py:139
|
||||
msgid "No file part: {}"
|
||||
msgstr "Pas de données de fichier : {}"
|
||||
|
||||
#: ../app.py:144
|
||||
msgid "No selected file"
|
||||
msgstr "Aucun fichier sélectionné."
|
||||
|
||||
#: ../app.py:148
|
||||
msgid "File saved in {}"
|
||||
msgstr "Fichier enregistré dans {}"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# pygettext ../../../app.py -o template.pot
|
||||
for locale in */LC_MESSAGES/template.pot; do
|
||||
/usr/bin/msgfmt -o ${locale%.*}.mo $locale
|
||||
done
|
|
@ -0,0 +1,49 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2022-11-03 12:59+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: ../app.py:25
|
||||
msgid "Found configuration file in {}"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:104
|
||||
msgid "Nothing to see here !"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:115
|
||||
msgid "Blinkin"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:122
|
||||
msgid "Rebooting..."
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:129
|
||||
msgid "Shutting down..."
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:139
|
||||
msgid "No file part: {}"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:144
|
||||
msgid "No selected file"
|
||||
msgstr ""
|
||||
|
||||
#: ../app.py:148
|
||||
msgid "File saved in {}"
|
||||
msgstr ""
|
||||
|
Loading…
Reference in New Issue