From d8d879380793561ed13ed36d77940899fcdfefbc Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Tue, 15 Nov 2022 17:00:36 +0100 Subject: [PATCH] Webgui l10n --- app.py | 25 ++++++- locales/en/LC_MESSAGES/template.pot | 109 +++++++++++++++++++++------- locales/fr/LC_MESSAGES/template.mo | Bin 1302 -> 1924 bytes locales/fr/LC_MESSAGES/template.pot | 68 +++++++++++++++++ locales/gen_mo.sh | 3 + locales/messages.pot | 17 ----- locales/template.pot | 57 --------------- static/script.js | 8 +- static/style.css | 6 ++ templates/main.html | 71 +++++++++--------- 10 files changed, 222 insertions(+), 142 deletions(-) delete mode 100644 locales/messages.pot delete mode 100644 locales/template.pot diff --git a/app.py b/app.py index 8de7c7e..eec0b61 100755 --- a/app.py +++ b/app.py @@ -23,7 +23,26 @@ from waitress import serve # l10n 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) diff --git a/locales/en/LC_MESSAGES/template.pot b/locales/en/LC_MESSAGES/template.pot index 7df0eee..2e57c1e 100644 --- a/locales/en/LC_MESSAGES/template.pot +++ b/locales/en/LC_MESSAGES/template.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" - - diff --git a/locales/fr/LC_MESSAGES/template.mo b/locales/fr/LC_MESSAGES/template.mo index ca9e8b2f63fdf010e4a8658e50ffc76262a6599c..f1562a25154a7144c4319e83ef352138ad375d91 100644 GIT binary patch delta 1055 zcmZwFJ!lj`6u|Mhzr}1LUhh`xO@gr#jK~h*GA|e+#azVL9-0V%f!FBhX-HQn- z0a4UKES6X+Lhve!)G6c|V`Cv{EEF576xLS$-(>?94$S^$-tNr2nc3GJPjV~YyR)l` z;!p>rW|TTBw(+2R!acZ|`UU&xZ{Z03#v$x!SL!65$1KjJmQ!!yLE>K84{@JTD=MaO zm=_OG7J7-Dn4nDb7Wd;C9>EW3|6}TB+)Mmx>Nk{eKXDj;rTq?q63?aPv6J;xAB}Ea zjA0K>ru`!3ISmgF5MLrYN$@cb+3|B6$M-mbTX+ippnN|}Rt!}W$WGO{)XCH->|%X& zl|~*1s)Xg-$g@=g$z%krLnK#d5l2AX&`ypJB zBORw9JHLo>w{w`s5IF#Klq#h)c&FKVN|GJau76^ZD8EGOgk)}}P{*i}=x&isI8^?Z za_es8$CHeDsVAsXWQS4)c4(cDG$qmFR7sGlZQXqiWru3YH^Ch>?Q7R2)y&iWf^-XE zSW`2)VqE94@pYuG>7_W?&J5ge>ycJP{ZiYlOm5mY zw}UWdnd_#aZSt;tZLnZ;pr*pQ=M$c3Hb^s4rMg*kgE+a8Ju^`JPnHGk#dWKbd)d(o z%@?sYLB*1rZ8kh+(1D~=X*TY<)-vmCvr%g{WLe41;j2iy^<*`Bx_8bR3Gb#^wP9d5 JiDV;N{tJ;PrZE5j delta 473 zcmXxgzb^xE7{~Fazphj%O_4UjiHb@Zi$B011_o(j=_Xaz^pex#dL0Dmpo6W$(Z7Jf zY&ThK{sJ2zVKCUepTm=U?)AOz<$KR_*UJo2-RErlN~jE(A(v#Dq$6CYCKk}fBKB|& zZ*dkMF^+GT#7`W@ZyZ7+Dl&l?T)=r8#SP4gbY+LdBpZ$24LQXehx@3Fu45u)d_W!G z3rjdf*I``4G2FyFR#6A=kOp#&OE^FsEymoUHx; DL2Eq= diff --git a/locales/fr/LC_MESSAGES/template.pot b/locales/fr/LC_MESSAGES/template.pot index de815ad..81dd1de 100644 --- a/locales/fr/LC_MESSAGES/template.pot +++ b/locales/fr/LC_MESSAGES/template.pot @@ -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 {}" diff --git a/locales/gen_mo.sh b/locales/gen_mo.sh index b20995d..0d2c1c0 100755 --- a/locales/gen_mo.sh +++ b/locales/gen_mo.sh @@ -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 diff --git a/locales/messages.pot b/locales/messages.pot deleted file mode 100644 index c1a34dd..0000000 --- a/locales/messages.pot +++ /dev/null @@ -1,17 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR ORGANIZATION -# FIRST AUTHOR , 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 \n" -"Language-Team: LANGUAGE \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" - - diff --git a/locales/template.pot b/locales/template.pot deleted file mode 100644 index c3434b2..0000000 --- a/locales/template.pot +++ /dev/null @@ -1,57 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR ORGANIZATION -# FIRST AUTHOR , 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 \n" -"Language-Team: LANGUAGE \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 "" - diff --git a/static/script.js b/static/script.js index 72f7431..1cbdd04 100644 --- a/static/script.js +++ b/static/script.js @@ -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 + "
" + 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 = "

"; } if (infos_array[i].loop == "true") { document.getElementById("loop_ind_" + infos_array[i].host).style.backgroundColor = "#78E738" diff --git a/static/style.css b/static/style.css index 3ac6f70..645e6d6 100644 --- a/static/style.css +++ b/static/style.css @@ -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; diff --git a/templates/main.html b/templates/main.html index 401e284..28862fb 100644 --- a/templates/main.html +++ b/templates/main.html @@ -13,54 +13,51 @@
-

Pilpil-server

+

{{gui_l10n['str_pilpil_title']}}

{{status_message}}

{{queue_msgs[0]}}

- - - - - - - - - - - - - - + + + + + + + + + + +

{% for host in hosts %}
-

{{ host }}

+

{{host}}

- - - -

{{status_message}}

-

- Link: + + + +

{{status_message}}

+

+ {{gui_l10n['str_link']}}:

-

Loop

-

Repeat

+

{{gui_l10n['str_loop']}}

+

{{gui_l10n['str_repeat']}}

-
{{queue_msgs[1]}} -
- +
+
+
- +
Filename{{gui_l10n['str_filename']}}
@@ -74,15 +71,15 @@ -->
- - - - - - - - - + + + + + + + + +