Webgui l10n

This commit is contained in:
ABelliqueux 2022-11-15 17:00:36 +01:00
parent 48183de587
commit d8d8793807
10 changed files with 222 additions and 142 deletions

23
app.py
View File

@ -24,6 +24,25 @@ from waitress import serve
LOCALE = os.getenv('LANG', 'en')
_ = gettext.translation('template', localedir='locales', languages=[LOCALE]).gettext
gui_l10n = { "str_pilpil_title" : _("Pilpil-server"),
"str_filename" : _("Media Files"),
"str_scan" : _("Scan"),
"str_previous" : _("Previous"),
"str_play" : _("Play"),
"str_pause" : _("Pause"),
"str_stop" : _("Stop"),
"str_next" : _("Next"),
"str_loop" : _("Loop"),
"str_repeat" : _("Repeat"),
"str_clear" : _("Clear"),
"str_sort" : _("Sort"),
"str_sync" : _("Sync"),
"str_poweroff" : _("Poweroff"),
"str_reboot" : _("Reboot"),
"str_blink" : _("Blink"),
"str_link" : _("Link"),
}
app = Flask(__name__)
app.config.from_file("defaults.toml", load=toml.load)
@ -302,7 +321,6 @@ def get_meta_data(host, xml_data, request_="status", m3u_=0):
media_infos = {host : host_medias}
if debug:
print(media_infos)
return media_infos
def get_playlist(host, xml_data, m3u=0):
@ -453,7 +471,8 @@ def main():
templateData = {
'hosts' : hosts,
'status_message' : status_message,
'queue_msgs' : queue_msgs
'queue_msgs' : queue_msgs,
'gui_l10n' : gui_l10n
}
return render_template('main.html', **templateData)

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-11-01 19:56+0100\n"
"POT-Creation-Date: 2022-11-15 16:34+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"
@ -14,53 +14,112 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: app.py:19
msgid "No file"
#: ../app.py:27
msgid "Pilpil-server"
msgstr ""
#: app.py:20
msgid "No files queued."
#: ../app.py:28
msgid "Media Files"
msgstr ""
#: app.py:22
#: ../app.py:29
msgid "Scan"
msgstr ""
#: ../app.py:30
msgid "Previous"
msgstr ""
#: ../app.py:31
msgid "Play"
msgstr ""
#: ../app.py:32
msgid "Pause"
msgstr ""
#: ../app.py:33
msgid "Stop"
msgstr ""
#: ../app.py:34
msgid "Next"
msgstr ""
#: ../app.py:35
msgid "Loop"
msgstr ""
#: ../app.py:36
msgid "Repeat"
msgstr ""
#: ../app.py:37
msgid "Clear"
msgstr ""
#: ../app.py:38
msgid "Sort"
msgstr ""
#: ../app.py:39
msgid "Sync"
msgstr ""
#: ../app.py:40
msgid "Poweroff"
msgstr ""
#: ../app.py:41
msgid "Reboot"
msgstr ""
#: ../app.py:42
msgid "Blink"
msgstr ""
#: ../app.py:43
msgid "Link"
msgstr ""
#: ../app.py:52
msgid "Found configuration file in {}"
msgstr ""
#: app.py:105
msgid "Port {} reachable"
#: ../app.py:56
msgid "No items"
msgstr ""
#: app.py:109
#: ../app.py:57
msgid "No files queued."
msgstr ""
#: ../app.py:168
msgid "{} reachable on {}"
msgstr ""
#: ../app.py:173
msgid "Error on connection to {} : {} : {} "
msgstr ""
#: app.py:123
#: ../app.py:190
msgid "{} of {} hosts found."
msgstr ""
#: app.py:169
msgid "{} files uploaded."
#: ../app.py:330
msgid "Playlist"
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
#: ../app.py:465
msgid "Idle"
msgstr ""
#: app.py:336
#: ../app.py:469
msgid "Searching network for live hosts..."
msgstr ""
#: app.py:373
#: ../app.py:510
msgid "Wrong command"
msgstr ""

Binary file not shown.

View File

@ -22,6 +22,74 @@ msgstr "Aucun fichier."
msgid "No files queued."
msgstr "Aucun fichier en attente."
#: ../app.py:27
msgid "Pilpil-server"
msgstr "Pilpil-server"
#: ../app.py:28
msgid "Media Files"
msgstr "Médias"
#: ../app.py:29
msgid "Scan"
msgstr "Scan réseau"
#: ../app.py:30
msgid "Previous"
msgstr "Précédent"
#: ../app.py:31
msgid "Play"
msgstr "Lecture"
#: ../app.py:32
msgid "Pause"
msgstr "Pause"
#: ../app.py:33
msgid "Stop"
msgstr "Stop"
#: ../app.py:34
msgid "Next"
msgstr "Suivant"
#: ../app.py:35
msgid "Loop"
msgstr "Boucler"
#: ../app.py:36
msgid "Repeat"
msgstr "Répéter"
#: ../app.py:37
msgid "Clear"
msgstr "Vider"
#: ../app.py:38
msgid "Sort"
msgstr "Trier"
#: ../app.py:39
msgid "Sync"
msgstr "Synchroniser"
#: ../app.py:40
msgid "Poweroff"
msgstr "Éteindre"
#: ../app.py:41
msgid "Reboot"
msgstr "Redémarrer"
#: ../app.py:42
msgid "Blink"
msgstr "Clignoter"
#: ../app.py:43
msgid "Link"
msgstr "Lien"
#: app.py:22
msgid "Found configuration file in {}"
msgstr "Fichier de configuration trouvé dans {}"

View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash
# pygettext -o template.pot ../app.py
#
# Change to script dir
cd "$(dirname "$0")"
for locale in */LC_MESSAGES/template.pot; do
/usr/bin/msgfmt -o ${locale%.*}.mo $locale
done

View File

@ -1,17 +0,0 @@
# 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"

View File

@ -1,57 +0,0 @@
# 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 ""

View File

@ -113,10 +113,10 @@ function addElement(type, attr, meta = 0, j = 0){
// Bouttons de commande
addEventListener("DOMContentLoaded", function() {
sendCmd("/scan");
sendCmd("/browse_local");
sendCmd("/all/rssi");
sendCmd("/all/list");
sendCmd("/all/browse");
sendCmd("/browse_local");
setTimeout(sendCmd, 3000, "/all/browse");
setTimeout(sendCmd, 4000, "/all/rssi");
adjustTl();
// Get filename when selected in table
@ -191,6 +191,8 @@ function parseResult(command, infos_array) {
if (infos_array[i].status) {
document.getElementById("status_"+infos_array[i].host).innerHTML = infos_array[i].file + " <br/> " + infos_array[i].time + " / " + infos_array[i].leng;
medias_status[infos_array[i].id] = infos_array[i].pos;
} else {
document.getElementById("status_"+infos_array[i].host).innerHTML = "<br><br>";
}
if (infos_array[i].loop == "true") {
document.getElementById("loop_ind_" + infos_array[i].host).style.backgroundColor = "#78E738"

View File

@ -133,6 +133,12 @@ tr:nth-child(2n+1) {background-color: #888;}
width: 100%;
margin: 0;
}
.file_selection {
cursor: pointer;
}
.file_selection:hover {
background-color: rgb(255, 136, 57);
}
.wl_indicator {
display: inline-block;
background-color: #bbb;

View File

@ -13,26 +13,23 @@
<body>
<div id="master_remote">
<div class="left_col">
<h2>Pilpil-server</h2>
<h2>{{gui_l10n['str_pilpil_title']}}</h2>
<p id="status_all">{{status_message}}</p>
<p id="filelist">{{queue_msgs[0]}}</p>
</div>
<div class="right_col">
<p class="buttons">
<button value="/scan" class="command btn btn-block btn-lg btn-default" role="button">&#x1f50d;<span class="btn_txt">Scan<br/>r&eacute;seau</span></button>
<button value="/all/previous" class="command btn btn-block btn-lg btn-default" role="button">&#x23ee;<span class="btn_txt">Pr&eacute;c.</span></button>
<button value="/all/play" class="command btn btn-block btn-lg btn-default" role="button">&#x23f5;<span class="btn_txt">Lecture</span></button>
<button value="/all/pause" class="command btn btn-block btn-lg btn-default" role="button">&#x23f8;<span class="btn_txt">Pause</span></button>
<button value="/all/stop" class="command btn btn-block btn-lg btn-default" role="button">&#x23f9;<span class="btn_txt">Stop</span></button>
<button value="/all/next" class="command btn btn-block btn-lg btn-default" role="button">&#x23ed;<span class="btn_txt">Suivant</span></button>
<button value="/all/repeat" class="command btn btn-block btn-lg btn-default" role="button">&#x1f502;<span class="btn_txt">R&eacute;p&eacute;ter<br/>&eacute;lem.</span></button>
<button value="/all/loop" class="command btn btn-block btn-lg btn-default" role="button">&#x1f501;<span class="btn_txt">Boucler<br/>liste</span></button>
<button value="/all/clear" class="command btn btn-block btn-lg btn-default" role="button">X<span class="btn_txt">Vider<br/>listes</span></button>
<button value="/all/enqueue/tst.mp4" class="command btn btn-block btn-lg btn-default" role="button">&#x3b2;<span class="btn_txt">tst.mp4</span></button>
<button value="/all/enqueue/tst1.mp4" class="command btn btn-block btn-lg btn-default" role="button">&#x3b2;<span class="btn_txt">tst1.mp4</span></button>
<button value="/all/enqueue/sangliers_1080.mp4" class="command btn btn-block btn-lg btn-default" role="button">&#x3b2;<span class="btn_txt">sangli.mp4</span></button>
<button value="/all/move/0/1" class="command btn btn-block btn-lg btn-default" role="button">&#x3b2;<span class="btn_txt">movePl</span></button>
<button value="/sync/all" class="command btn btn-block btn-lg btn-default" role="button">&#x21ad;<span class="btn_txt">Sync</span></button>
<button value="/scan" class="command btn btn-block btn-lg btn-default" role="button">&#x1f50d;<span class="btn_txt">{{gui_l10n['str_scan']}}</span></button>
<button value="/all/previous" class="command btn btn-block btn-lg btn-default" role="button">&#x23ee;<span class="btn_txt">{{gui_l10n['str_previous']}}</span></button>
<button value="/all/play" class="command btn btn-block btn-lg btn-default" role="button">&#x23f5;<span class="btn_txt">{{gui_l10n['str_play']}}</span></button>
<button value="/all/pause" class="command btn btn-block btn-lg btn-default" role="button">&#x23f8;<span class="btn_txt">{{gui_l10n['str_pause']}}</span></button>
<button value="/all/stop" class="command btn btn-block btn-lg btn-default" role="button">&#x23f9;<span class="btn_txt">{{gui_l10n['str_stop']}}</span></button>
<button value="/all/next" class="command btn btn-block btn-lg btn-default" role="button">&#x23ed;<span class="btn_txt">{{gui_l10n['str_next']}}</span></button>
<button value="/all/repeat" class="command btn btn-block btn-lg btn-default" role="button">&#x1f502;<span class="btn_txt">{{gui_l10n['str_repeat']}}</span></button>
<button value="/all/loop" class="command btn btn-block btn-lg btn-default" role="button">&#x1f501;<span class="btn_txt">{{gui_l10n['str_loop']}}</span></button>
<button value="/all/clear" class="command btn btn-block btn-lg btn-default" role="button">X<span class="btn_txt">{{gui_l10n['str_clear']}}</span></button>
<button value="/all/move/0/1" class="command btn btn-block btn-lg btn-default" role="button">&#x3b2;<span class="btn_txt">{{gui_l10n['str_sort']}}</span></button>
<button value="/sync/all" class="command btn btn-block btn-lg btn-default" role="button">&#x21ad;<span class="btn_txt">{{gui_l10n['str_sync']}}</span></button>
</p>
</div>
</div>
@ -41,26 +38,26 @@
<div class="left_col">
<h2>{{host}}</h2>
<div class="col_1">
<button value="/{{host}}/poweroff" class="command btn btn-block btn-lg btn-default" role="button">&#x23fb;<span class="btn_txt">&Eacute;teindre</span></button>
<button value="/{{host}}/reboot" class="command btn btn-block btn-lg btn-default" role="button">&#x21BA;<span class="btn_txt">Red&eacute;marrer</span></button>
<button value="/{{host}}/blink" class="command btn btn-block btn-lg btn-default" role="button">&#x1F4A1;<span class="btn_txt">Blink</span></button>
<button value="/{{host}}/poweroff" class="command btn btn-block btn-lg btn-default" role="button">&#x23fb;<span class="btn_txt">{{gui_l10n['str_poweroff']}}</span></button>
<button value="/{{host}}/reboot" class="command btn btn-block btn-lg btn-default" role="button">&#x21BA;<span class="btn_txt">{{gui_l10n['str_reboot']}}</span></button>
<button value="/{{host}}/blink" class="command btn btn-block btn-lg btn-default" role="button">&#x1F4A1;<span class="btn_txt">{{gui_l10n['str_blink']}}</span></button>
<p id="status_{{host}}">{{status_message}}</p>
<p id="signal_{{host}}">
<span style="">Link:</span>
<span style="">{{gui_l10n['str_link']}}:</span>
<span class="wl_indicator" id="wl_0"></span>
<span class="wl_indicator" id="wl_1"></span>
<span class="wl_indicator" id="wl_2"></span>
<span class="wl_indicator" id="wl_3"></span>
</p>
<p id="loop_ind_{{ host }}" class="indicator">Loop</p>
<p id="repeat_ind_{{ host }}" class="indicator">Repeat</p>
<p id="loop_ind_{{host}}" class="indicator">{{gui_l10n['str_loop']}}</p>
<p id="repeat_ind_{{host}}" class="indicator">{{gui_l10n['str_repeat']}}</p>
</div>
<div class="col_2">
<div>{{queue_msgs[1]}}
<div>
<div id="playlist_{{host}}" class="table_cont">
<table id="file_sel_{{host}}">
<tr>
<th>Filename</th>
<th>{{gui_l10n['str_filename']}}</th>
</tr>
</table>
</div>
@ -74,15 +71,15 @@
-->
</div>
<div class="buttons">
<button value="/{{host}}/previous" class="command btn btn-block btn-lg btn-default" role="button">&#x23ee;<span class="btn_txt">Pr&eacute;c.</span></button>
<button value="/{{host}}/play" class="command btn btn-block btn-lg btn-default" role="button">&#x23f5;<span class="btn_txt">Lecture</span></button>
<button value="/{{host}}/pause" class="command btn btn-block btn-lg btn-default" role="button">&#x23f8;<span class="btn_txt">Pause</span></button>
<button value="/{{host}}/stop" class="command btn btn-block btn-lg btn-default" role="button">&#x23f9;<span class="btn_txt">Stop</span></button>
<button value="/{{host}}/next" class="command btn btn-block btn-lg btn-default" role="button">&#x23ed;<span class="btn_txt">Suivant</span></button>
<button value="/{{host}}/repeat" class="command btn btn-block btn-lg btn-default" role="button">&#x1f502;<span class="btn_txt">R&eacute;p&eacute;ter<br/>&eacute;lem.</span></button>
<button value="/{{host}}/loop" class="command btn btn-block btn-lg btn-default" role="button">&#x1f501;<span class="btn_txt">Boucler<br/>liste</span></button>
<button value="/{{host}}/clear" class="command btn btn-block btn-lg btn-default" role="button">X<span class="btn_txt">Vider<br/>liste</span></button>
<button id="toggle_val_{{host}}}" value="/{{host}}/sort/1/id" class="command btn btn-block btn-lg btn-default" role="button">&#x1f500;<span class="btn_txt">Trier<br/>liste</span></button>
<button value="/{{host}}/previous" class="command btn btn-block btn-lg btn-default" role="button">&#x23ee;<span class="btn_txt">{{gui_l10n['str_previous']}}</span></button>
<button value="/{{host}}/play" class="command btn btn-block btn-lg btn-default" role="button">&#x23f5;<span class="btn_txt">{{gui_l10n['str_play']}}</span></button>
<button value="/{{host}}/pause" class="command btn btn-block btn-lg btn-default" role="button">&#x23f8;<span class="btn_txt">{{gui_l10n['str_pause']}}</span></button>
<button value="/{{host}}/stop" class="command btn btn-block btn-lg btn-default" role="button">&#x23f9;<span class="btn_txt">{{gui_l10n['str_stop']}}</span></button>
<button value="/{{host}}/next" class="command btn btn-block btn-lg btn-default" role="button">&#x23ed;<span class="btn_txt">{{gui_l10n['str_next']}}</span></button>
<button value="/{{host}}/repeat" class="command btn btn-block btn-lg btn-default" role="button">&#x1f502;<span class="btn_txt">{{gui_l10n['str_repeat']}}</span></button>
<button value="/{{host}}/loop" class="command btn btn-block btn-lg btn-default" role="button">&#x1f501;<span class="btn_txt">{{gui_l10n['str_loop']}}</span></button>
<button value="/{{host}}/clear" class="command btn btn-block btn-lg btn-default" role="button">X<span class="btn_txt">{{gui_l10n['str_clear']}}</span></button>
<button id="toggle_val_{{host}}}" value="/{{host}}/sort/1/id" class="command btn btn-block btn-lg btn-default" role="button">&#x1f500;<span class="btn_txt">{{gui_l10n['str_sort']}}</span></button>
</div>
</div>
</div>