French l10n of app
This commit is contained in:
parent
713a1eef79
commit
d33d9f932a
38
app.py
38
app.py
|
@ -6,9 +6,20 @@ import http.client, ssl
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from flask import Flask, render_template, request, make_response, jsonify
|
from flask import Flask, render_template, request, make_response, jsonify
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
import gettext
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# ~ _ = gettext.gettext
|
||||||
|
|
||||||
|
LOCALE = os.getenv('LANG', 'en')
|
||||||
|
|
||||||
|
_ = gettext.translation('template', localedir='locales', languages=[LOCALE]).gettext
|
||||||
|
|
||||||
|
queue_msgs = [ _("No items"),
|
||||||
|
_("No files queued."),
|
||||||
|
]
|
||||||
|
|
||||||
# Load config defaults, then look for other config files
|
# Load config defaults, then look for other config files
|
||||||
app.config.from_file("defaults.toml", load=toml.load)
|
app.config.from_file("defaults.toml", load=toml.load)
|
||||||
config_locations = ["./", "~/.", "~/.config/"]
|
config_locations = ["./", "~/.", "~/.config/"]
|
||||||
|
@ -16,7 +27,7 @@ for location in config_locations:
|
||||||
# Optional config files, ~ is expanded to $HOME on *nix, %USERPROFILE% on windows
|
# Optional config files, ~ is expanded to $HOME on *nix, %USERPROFILE% on windows
|
||||||
# ~ app.config.from_file("videopi.toml", load=toml.load, silent=True)
|
# ~ app.config.from_file("videopi.toml", load=toml.load, silent=True)
|
||||||
if app.config.from_file(os.path.expanduser( location + "pilpil-server.toml"), load=toml.load, silent=True):
|
if app.config.from_file(os.path.expanduser( location + "pilpil-server.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) ) )
|
||||||
# ~ app.config.from_file(os.path.expanduser("~/.config/videopi.toml"), load=toml.load, silent=True)
|
# ~ app.config.from_file(os.path.expanduser("~/.config/videopi.toml"), load=toml.load, silent=True)
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -99,11 +110,11 @@ def isup(host_l, port):
|
||||||
s.settimeout(3.0)
|
s.settimeout(3.0)
|
||||||
s.connect((host_l, port))
|
s.connect((host_l, port))
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print( "Port " + str(port) + " reachable")
|
print( _("Port {} reachable").format(str(port)) )
|
||||||
return 1
|
return 1
|
||||||
except (socket.error, socket.timeout) as e:
|
except (socket.error, socket.timeout) as e:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("Error on connection to " + host_l + ":" + str(port) + ": %s" % e)
|
print( _("Error on connection to {} : {} : {} ").format(host_l, str(port), e) )
|
||||||
return 0
|
return 0
|
||||||
finally:
|
finally:
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -117,7 +128,7 @@ def checkHosts(host_l):
|
||||||
else:
|
else:
|
||||||
hostup.append(lhost)
|
hostup.append(lhost)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print( str(len(hostup)) + " of " + hosts_number + " hosts found.")
|
print( _("{} of {} hosts found.").format(str(len(hostup)), hosts_number))
|
||||||
return hostup, hostdown
|
return hostup, hostdown
|
||||||
|
|
||||||
# File utilities
|
# File utilities
|
||||||
|
@ -163,7 +174,7 @@ def syncMediaFolder(media_folder_local, media_folder_remote, hostl, sync_facilit
|
||||||
transfer_ok = 0
|
transfer_ok = 0
|
||||||
for media in media_list:
|
for media in media_list:
|
||||||
transfer_ok += httpUpload(media, hostl, trailing_slash)
|
transfer_ok += httpUpload(media, hostl, trailing_slash)
|
||||||
return str(transfer_ok) + " files uploaded."
|
return _("{} files uploaded.").format(str(transfer_ok))
|
||||||
|
|
||||||
# Check sync utility exists
|
# Check sync utility exists
|
||||||
elif which(sync_facility):
|
elif which(sync_facility):
|
||||||
|
@ -246,10 +257,10 @@ def sendCommand(host, arg0, arg1, arg2):
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
except http.client.HTTPException:
|
except http.client.HTTPException:
|
||||||
print("Connection to " + host + " timed out")
|
print( _("Connection to {} timed out").format(host) )
|
||||||
return "Connection to " + host + " timed out"
|
return _("Connection to {} timed out").format(host)
|
||||||
except:
|
except:
|
||||||
return "Error while connecting to " + host + ":" + str(portl)
|
return _("Error while connecting to {}:{}").format(host, str(portl))
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
# Parse response
|
# Parse response
|
||||||
|
@ -325,16 +336,17 @@ def sendCommand(host, arg0, arg1, arg2):
|
||||||
}
|
}
|
||||||
return playlist_overview
|
return playlist_overview
|
||||||
|
|
||||||
status_message = "Idle"
|
status_message = _("Idle")
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main():
|
def main():
|
||||||
global hosts
|
global hosts
|
||||||
status_message = "Searching network for live hosts..."
|
status_message = _("Searching network for live hosts...")
|
||||||
# ~ hosts_available, hosts_unavailable = checkHosts(hosts)
|
# ~ hosts_available, hosts_unavailable = checkHosts(hosts)
|
||||||
templateData = {
|
templateData = {
|
||||||
'hosts' : hosts,
|
'hosts' : hosts,
|
||||||
'status_message' : status_message
|
'status_message' : status_message,
|
||||||
|
'queue_msgs' : queue_msgs
|
||||||
}
|
}
|
||||||
return render_template('main.html', **templateData)
|
return render_template('main.html', **templateData)
|
||||||
|
|
||||||
|
@ -367,14 +379,14 @@ def sync(host):
|
||||||
def action(host, arg0, arg1, arg2):
|
def action(host, arg0, arg1, arg2):
|
||||||
status_message = "Idle"
|
status_message = "Idle"
|
||||||
if (arg0 not in cmd_player) and (arg0 not in cmd_server):
|
if (arg0 not in cmd_player) and (arg0 not in cmd_server):
|
||||||
status_message = "<p>Wrong command</p>"
|
status_message = "<p>{}</p>".format(_("Wrong command"))
|
||||||
elif host == "all":
|
elif host == "all":
|
||||||
resp = []
|
resp = []
|
||||||
for hostl in hosts_available:
|
for hostl in hosts_available:
|
||||||
resp.append( sendCommand(hostl, arg0, arg1, arg2) )
|
resp.append( sendCommand(hostl, arg0, arg1, arg2) )
|
||||||
status_message = resp
|
status_message = resp
|
||||||
elif host not in hosts_available:
|
elif host not in hosts_available:
|
||||||
status_message = "<p>Host is not reachable</p>"
|
status_message = "<p>{}</p>".format("Host is not reachable")
|
||||||
else:
|
else:
|
||||||
status_message = sendCommand(host, arg0, arg1, arg2)
|
status_message = sendCommand(host, arg0, arg1, arg2)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,66 @@
|
||||||
|
# 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-01 19:56+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:19
|
||||||
|
msgid "No file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:20
|
||||||
|
msgid "No files queued."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:22
|
||||||
|
msgid "Found configuration file in {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:105
|
||||||
|
msgid "Port {} reachable"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:109
|
||||||
|
msgid "Error on connection to {} : {} : {} "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:123
|
||||||
|
msgid "{} of {} hosts found."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:169
|
||||||
|
msgid "{} files uploaded."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:252 app.py:253
|
||||||
|
msgid "Connection to {} timed out"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:255
|
||||||
|
msgid "Error while connecting to {}:{}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:331
|
||||||
|
msgid "Idle"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:336
|
||||||
|
msgid "Searching network for live hosts..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:373
|
||||||
|
msgid "Wrong command"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,64 @@
|
||||||
|
# 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-01 19:56+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:19
|
||||||
|
msgid "No file"
|
||||||
|
msgstr "Aucun fichier."
|
||||||
|
|
||||||
|
#: app.py:20
|
||||||
|
msgid "No files queued."
|
||||||
|
msgstr "Aucun fichier en attente."
|
||||||
|
|
||||||
|
#: app.py:22
|
||||||
|
msgid "Found configuration file in {}"
|
||||||
|
msgstr "Fichier de configuration trouvé dans {}"
|
||||||
|
|
||||||
|
#: app.py:105
|
||||||
|
msgid "Port {} reachable"
|
||||||
|
msgstr "Port {} accessible"
|
||||||
|
|
||||||
|
#: app.py:109
|
||||||
|
msgid "Error on connection to {} : {} : {} "
|
||||||
|
msgstr "Erreur lors de la connexion à {} : {} : {} "
|
||||||
|
|
||||||
|
#: app.py:123
|
||||||
|
msgid "{} of {} hosts found."
|
||||||
|
msgstr "{} de {} clients trouvés."
|
||||||
|
|
||||||
|
#: app.py:169
|
||||||
|
msgid "{} files uploaded."
|
||||||
|
msgstr "{} fichiers envoyés."
|
||||||
|
|
||||||
|
#: app.py:252 app.py:253
|
||||||
|
msgid "Connection to {} timed out"
|
||||||
|
msgstr "Temps d'attente dépassé : {} "
|
||||||
|
|
||||||
|
#: app.py:255
|
||||||
|
msgid "Error while connecting to {}:{}"
|
||||||
|
msgstr "Erreur pendant la connexion à {}:{}"
|
||||||
|
|
||||||
|
#: app.py:331
|
||||||
|
msgid "Idle"
|
||||||
|
msgstr "Innocupé"
|
||||||
|
|
||||||
|
#: app.py:336
|
||||||
|
msgid "Searching network for live hosts..."
|
||||||
|
msgstr "Recherche des clients sur le réseau..."
|
||||||
|
|
||||||
|
#: app.py:373
|
||||||
|
msgid "Wrong command"
|
||||||
|
msgstr "Commande inconnue"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
for locale in */LC_MESSAGES/template.pot; do
|
||||||
|
/usr/bin/msgfmt -o ${locale%.*}.mo $locale
|
||||||
|
done
|
|
@ -0,0 +1,17 @@
|
||||||
|
# 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-02 18:58+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"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
# 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-01 19:56+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:22
|
||||||
|
msgid "Found configuration file in {}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:105
|
||||||
|
msgid "Port {} reachable"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:109
|
||||||
|
msgid "Error on connection to {} : {} : {} "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:123
|
||||||
|
msgid "{} of {} hosts found."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:169
|
||||||
|
msgid "{} files uploaded."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:252 app.py:253
|
||||||
|
msgid "Connection to {} timed out"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:255
|
||||||
|
msgid "Error while connecting to {}:{}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:331
|
||||||
|
msgid "Idle"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:336
|
||||||
|
msgid "Searching network for live hosts..."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: app.py:373
|
||||||
|
msgid "Wrong command"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -263,7 +263,7 @@ function parseResult(command, infos_array) {
|
||||||
scanInterval = 10000;
|
scanInterval = 10000;
|
||||||
document.getElementById("status_all").innerHTML = "Scan intarvel set to " + scanInterval;
|
document.getElementById("status_all").innerHTML = "Scan intarvel set to " + scanInterval;
|
||||||
}
|
}
|
||||||
document.getElementById("status_all").innerHTML = host_up.length + " client(s) found.";
|
document.getElementById("status_all").innerHTML = host_up.length + " client(s).";
|
||||||
break;
|
break;
|
||||||
case "/browse":
|
case "/browse":
|
||||||
var html_table = "<table>" +
|
var html_table = "<table>" +
|
||||||
|
@ -278,7 +278,7 @@ function parseResult(command, infos_array) {
|
||||||
"</tr>" ;
|
"</tr>" ;
|
||||||
}
|
}
|
||||||
html_table += "</table>";
|
html_table += "</table>";
|
||||||
document.getElementById("filelist").innerHTML += html_table;
|
document.getElementById("filelist").innerHTML = html_table;
|
||||||
break;
|
break;
|
||||||
case "/all/rssi":
|
case "/all/rssi":
|
||||||
var signal_color = 40;
|
var signal_color = 40;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="master_remote">
|
<div id="master_remote">
|
||||||
<div class="left_col">
|
<div class="left_col">
|
||||||
<h2>Videopi commander</h2>
|
<h2>Pilpil-server</h2>
|
||||||
<p id="status_all">{{status_message}}</p>
|
<p id="status_all">{{status_message}}</p>
|
||||||
<p id="filelist">No files.</p>
|
<p id="filelist">{{queue_msgs[0]}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="right_col">
|
<div class="right_col">
|
||||||
<p class="buttons">
|
<p class="buttons">
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
<p id="repeat_ind_{{ host }}" class="indicator">Repeat</p>
|
<p id="repeat_ind_{{ host }}" class="indicator">Repeat</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col_2">
|
<div class="col_2">
|
||||||
<p id="playlist_{{ host }}">No files queued.</p>
|
<p id="playlist_{{ host }}">{{queue_msgs[1]}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="right_col">
|
<div class="right_col">
|
||||||
|
|
Loading…
Reference in New Issue