changeset 92:7a79cb5ed43b

add subtitles in video metadata and <track /> elements
author souliane <souliane@mailoo.org>
date Tue, 16 Jun 2015 20:31:16 +0200
parents 2de2c50a796d
children 9ae3d9c8b28a
files locale/fr/LC_MESSAGES/django.po sat_website/media.py templates/sat_website/gallery.html templates/sat_website/video.html
diffstat 4 files changed, 106 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/locale/fr/LC_MESSAGES/django.po	Tue Jun 16 17:36:08 2015 +0200
+++ b/locale/fr/LC_MESSAGES/django.po	Tue Jun 16 20:31:16 2015 +0200
@@ -7,8 +7,8 @@
 msgstr ""
 "Project-Id-Version: 0.0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-06-16 17:21+0200\n"
-"PO-Revision-Date: 2015-06-16 17:21+0100\n"
+"POT-Creation-Date: 2015-06-16 20:29+0200\n"
+"PO-Revision-Date: 2015-06-16 20:29+0100\n"
 "Last-Translator: Salut à Toi <contact@salut-a-toi.org>\n"
 "Language-Team: français <goffi@goffi.org>\n"
 "Language: fr\n"
@@ -213,64 +213,68 @@
 msgid "Subscription to Salut à Toi"
 msgstr "Adhésion à Salut à Toi"
 
-#: sat_website/media.py:40
+#: sat_website/media.py:32 sat_website/media.py:56
+msgid "subtitles"
+msgstr "sous-titres"
+
+#: sat_website/media.py:54
 msgid "Membership campaign for Libervia"
 msgstr "Campagne d'adhésion pour Libervia"
 
-#: sat_website/media.py:42 sat_website/media.py:45 sat_website/media.py:47
-#: sat_website/media.py:49 sat_website/media.py:54 sat_website/media.py:57
-#: sat_website/media.py:59 sat_website/media.py:61 sat_website/media.py:66
-#: sat_website/media.py:71 sat_website/media.py:76 sat_website/media.py:81
-#: sat_website/media.py:86 sat_website/media.py:89 sat_website/media.py:91
-#: sat_website/media.py:96 sat_website/media.py:101
+#: sat_website/media.py:56 sat_website/media.py:59 sat_website/media.py:61
+#: sat_website/media.py:63 sat_website/media.py:68 sat_website/media.py:71
+#: sat_website/media.py:73 sat_website/media.py:75 sat_website/media.py:80
+#: sat_website/media.py:85 sat_website/media.py:90 sat_website/media.py:95
+#: sat_website/media.py:100 sat_website/media.py:103 sat_website/media.py:105
+#: sat_website/media.py:110 sat_website/media.py:115
 msgid "version"
 msgstr "version"
 
-#: sat_website/media.py:42 sat_website/media.py:45 sat_website/media.py:47
-#: sat_website/media.py:49 sat_website/media.py:54 sat_website/media.py:57
-#: sat_website/media.py:59 sat_website/media.py:61 sat_website/media.py:66
-#: sat_website/media.py:71 sat_website/media.py:76 sat_website/media.py:81
-#: sat_website/media.py:86 sat_website/media.py:89 sat_website/media.py:91
-#: sat_website/media.py:96 sat_website/media.py:101
+#: sat_website/media.py:56 sat_website/media.py:59 sat_website/media.py:61
+#: sat_website/media.py:63 sat_website/media.py:68 sat_website/media.py:71
+#: sat_website/media.py:73 sat_website/media.py:75 sat_website/media.py:80
+#: sat_website/media.py:85 sat_website/media.py:90 sat_website/media.py:95
+#: sat_website/media.py:100 sat_website/media.py:103 sat_website/media.py:105
+#: sat_website/media.py:110 sat_website/media.py:115
 msgid "year"
 msgstr "année"
 
-#: sat_website/media.py:44
+#: sat_website/media.py:58
 msgid "Overview"
 msgstr "Aperçu"
 
-#: sat_website/media.py:45 sat_website/media.py:47 sat_website/media.py:49
-#: sat_website/media.py:54 sat_website/media.py:57 sat_website/media.py:59
-#: sat_website/media.py:61 sat_website/media.py:66 sat_website/media.py:71
-#: sat_website/media.py:91
+#: sat_website/media.py:59 sat_website/media.py:61 sat_website/media.py:63
+#: sat_website/media.py:68 sat_website/media.py:71 sat_website/media.py:73
+#: sat_website/media.py:75 sat_website/media.py:80 sat_website/media.py:85
+#: sat_website/media.py:105
 msgid "frontend"
 msgstr "interface"
 
-#: sat_website/media.py:46
+#: sat_website/media.py:60
 msgid "Optional security check"
 msgstr "Vérification de sécurité (optionnelle)"
 
-#: sat_website/media.py:48
+#: sat_website/media.py:62
 msgid "Rich text editor"
 msgstr "Éditeur de texte riche"
 
-#: sat_website/media.py:52
+#: sat_website/media.py:66
 msgid "Demo of the new Libervia UI, and of the collective radio feature"
 msgstr "Démo de la nouvelle interface de Libervia, et de la radio collective"
 
-#: sat_website/media.py:56
+#: sat_website/media.py:70
 msgid "Libervia's login page"
 msgstr "Page d'identification de Libervia"
 
-#: sat_website/media.py:58 templates/sat_website/frontends.html:34
+#: sat_website/media.py:72 templates/sat_website/frontends.html:34
 msgid "Libervia's main view"
 msgstr "Vue principale de Libervia"
 
-#: sat_website/media.py:60
+#: sat_website/media.py:74
 msgid "Wix showing a french Tarot play"
 msgstr "Wix montrant un jeu de tarot"
 
-#: sat_website/media.py:64
+#: sat_website/media.py:78
 msgid ""
 "This video focuses on Libervia. The UI is really outdated, but we can see "
 "some features"
@@ -278,43 +282,43 @@
 "Cette vidéo se concentre sur Libervia. C'est une vieille interface, mais on "
 "peut voir quelques fonctionnalités"
 
-#: sat_website/media.py:70
+#: sat_website/media.py:84
 msgid "Server administration from the web frontend Libervia."
 msgstr "Administration du serveur depuis l'interface web Libervia."
 
-#: sat_website/media.py:74
+#: sat_website/media.py:88
 msgid "Use ad-hoc commands to control a VLC player from Libervia"
 msgstr ""
 "Utilisation des commandes ad-hoc pour contrôler un lecteur VLC depuis "
 "Libervia"
 
-#: sat_website/media.py:79
+#: sat_website/media.py:93
 msgid "Exporting a command: an FTP client is exported to a Gajim contact"
 msgstr ""
 "Export de commande: un client FTP est exporté à un contact utilisant Gajim"
 
-#: sat_website/media.py:84
+#: sat_website/media.py:98
 msgid "How to copy and pipe streams over XMPP"
 msgstr "Comment copier et transférer des flux de tubes (pipes) via XMPP"
 
-#: sat_website/media.py:86 sat_website/templatetags/utils.py:98
+#: sat_website/media.py:100 sat_website/templatetags/utils.py:98
 msgid "language"
 msgstr "langue"
 
-#: sat_website/media.py:88
+#: sat_website/media.py:102
 msgid "Cowsay sent in conversation through jp"
 msgstr "« Cowsay » envoyé dans une discussion via jp"
 
-#: sat_website/media.py:90 templates/sat_website/frontends.html:41
+#: sat_website/media.py:104 templates/sat_website/frontends.html:41
 msgid "Primitivus showing a french Tarot play"
 msgstr "Primitivus montrant un jeu de tarot"
 
-#: sat_website/media.py:94
+#: sat_website/media.py:108
 msgid "This video shows french Tarot game, and how to use Thunderbird with SàT"
 msgstr ""
 "Cette vidéo montre un jeu de tarot, et comment utiliser Thunderbird avec SàT"
 
-#: sat_website/media.py:99
+#: sat_website/media.py:113
 msgid "The first video shows wix, primitivus and jp"
 msgstr "La première vidéo montre Wix, Primitivus et Jp"
 
@@ -368,7 +372,7 @@
 msgid "Get in touch"
 msgstr "Nous contacter"
 
-#: sat_website/views.py:44 templates/sat_website/membership.html:46
+#: sat_website/views.py:44 templates/sat_website/membership.html:45
 msgid "Association"
 msgstr "Association"
 
@@ -1153,8 +1157,9 @@
 msgid "Your idea here"
 msgstr "Votre idée ici"
 
-#: templates/sat_website/gallery.html:41 templates/sat_website/gallery.html:84
-#: templates/sat_website/membership.html:37
+#: templates/sat_website/gallery.html:40
+#: templates/sat_website/membership.html:36
+#: templates/sat_website/video.html:35
 #, python-format
 msgid ""
 "Your browser doesn't manage the « video » tag, you should update, e.g. with "
@@ -1272,11 +1277,11 @@
 msgid "Join the association"
 msgstr "Adhérez à l'association"
 
-#: templates/sat_website/membership.html:43
+#: templates/sat_website/membership.html:42
 msgid "About the association"
 msgstr "Concernant l'association"
 
-#: templates/sat_website/membership.html:45
+#: templates/sat_website/membership.html:44
 msgid ""
 "We want it to be as transparent as the software. You can read about its "
 "mission, its organisation and check the official documents."
@@ -1285,11 +1290,11 @@
 "renseigner sur sa mission, son organisation et consulter les documents "
 "officiels."
 
-#: templates/sat_website/membership.html:51
+#: templates/sat_website/membership.html:50
 msgid "Become a member"
 msgstr "Devenir membre"
 
-#: templates/sat_website/membership.html:53
+#: templates/sat_website/membership.html:52
 #, python-format
 msgid ""
 "For 2015, we need about %(asso_finance_target)s € for:\n"
@@ -1329,7 +1334,7 @@
 "%(asso_members_target)s adhésions avant le 31 décembre 2015 !\n"
 "            "
 
-#: templates/sat_website/membership.html:68
+#: templates/sat_website/membership.html:67
 msgid ""
 "The membership lasts exactly one year and isn't automatically renewed: you "
 "have to renew it yourself and you can change the amount of your subscription "
@@ -1339,7 +1344,7 @@
 "la renouveler vous-même et vous pouvez modifier le montant de votre "
 "cotisation d'une année sur l'autre."
 
-#: templates/sat_website/membership.html:70
+#: templates/sat_website/membership.html:69
 msgid ""
 "To join the association without paying any subscription or to proceed with a "
 "bank transfer, please use our internal form:"
@@ -1347,11 +1352,11 @@
 "Pour rejoindre l'association sans payer de cotisation, ou bien pour procéder "
 "par virement bancaire, merci d'utiliser notre formulaire interne."
 
-#: templates/sat_website/membership.html:73
+#: templates/sat_website/membership.html:72
 msgid "Join for free or proceed with a transfer"
 msgstr "Adhérer gratuitement ou procéder par virement"
 
-#: templates/sat_website/membership.html:75
+#: templates/sat_website/membership.html:74
 msgid ""
 "If you prefer to proceed by card, you can directly use a secure payment "
 "service hosted by our bank. We unfortunately cannot pre-fill the form "
@@ -1364,7 +1369,7 @@
 "montant de cotisation positif parmi ceux définis dans le règlement "
 "intérieur : 10, 20, 30, 50, 80 ou 100."
 
-#: templates/sat_website/membership.html:78
+#: templates/sat_website/membership.html:77
 msgid "Join and proceed by card"
 msgstr "Adhérer et procéder par carte"
 
--- a/sat_website/media.py	Tue Jun 16 17:36:08 2015 +0200
+++ b/sat_website/media.py	Tue Jun 16 20:31:16 2015 +0200
@@ -25,7 +25,21 @@
 import os.path
 
 ImageDesc = namedtuple("ImageDesc", "path description data")
-VideoDesc = namedtuple("VideoDesc", "paths description poster data")
+
+class VideoDesc(namedtuple("VideoDesc", "paths description poster data")):
+    @property
+    def subtitles(self):
+        key = _(u"subtitles")
+        if key not in self.data:
+            return {}
+        result = OrderedDict()
+        for lang in self.data[key]:
+            try:
+                result[lang] = os.path.splitext(self.paths[lang])[0] + '.vtt'
+            except IndexError:
+                # FIXME: subtitles for a lang that is not in self.paths are ignored
+                pass
+        return result
 
 screencasts = os.path.join(settings.MEDIA_EXTERNAL_URL, "screencasts") + "/"
 video = os.path.join(settings.MEDIA_EXTERNAL_URL, "video") + "/"
@@ -39,7 +53,7 @@
                            "fr": video + "libervia_adhesion_2015_fr.webm"}),
               _(u"Membership campaign for Libervia"),
               video + "posters/libervia_adhesion_2015.png",
-              {_(u"version"): "0.5", _(u"year"): "2015"}),
+              {_(u"version"): "0.5", _(u"year"): "2015", _(u"subtitles"): ["en", "fr"]}),
 
     ImageDesc("images/screenshots/0.5/overview_libervia.png", _(u"Overview"),
               {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}),
--- a/templates/sat_website/gallery.html	Tue Jun 16 17:36:08 2015 +0200
+++ b/templates/sat_website/gallery.html	Tue Jun 16 20:31:16 2015 +0200
@@ -78,10 +78,7 @@
                         {% for entry in media %}
                             <div class="item{% if not forloop.counter0 %} active{% endif %}">
                                 {% if entry.poster %}
-                                    <video class="img-responsive" width="640" height="400" poster="{{ entry.poster }}" controls preload="none">
-                                        <source src="{{ entry.paths|select_video_path }}" type='video/webm; codecs="vp8.0, vorbis"'>
-                                        {% blocktrans with firefox="<a href=\"http://www.mozilla.org/\">Firefox</a>" %}Your browser doesn't manage the « video » tag, you should update, e.g. with the last {{ firefox }}.{% endblocktrans %}
-                                    </video>
+                                    {% include "sat_website/video.html" with entry=entry style="img-responsive" width=640 height=400 %}
                                 {% else %}
                                     <img class="img-responsive" src="{% static entry.path %}">                            
                                 {% endif %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/sat_website/video.html	Tue Jun 16 20:31:16 2015 +0200
@@ -0,0 +1,36 @@
+{% comment %}
+SàT website: Salut à Toi's presentation website
+Copyright (C) 2012  Jérôme Poisson (goffi@goffi.org)
+
+This file is part of SàT website.
+
+SàT website is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Foobar is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
+{% endcomment %}
+
+{% load i18n %}
+{% load staticfiles %}
+{% load utils %}
+{% get_current_language as LANGUAGE_CODE %}
+
+<video class="{{style}}"
+       {% if width %}width="{{width}}"{% endif %}
+       {% if width %}height="{{height}}"{% endif %}
+       poster="{{ entry.poster }}" controls preload="none">
+    <source src="{{ entry.paths|select_video_path }}" type='video/webm; codecs="vp8.0, vorbis"'>
+    {% for srclang, path in entry.subtitles.items %}
+        {% get_language_info for srclang as lang %}
+        <track label="{{lang.name_local}}" src="{{path}}" kind="subtitles" srclang="{{srclang}}" {% if srclang == LANGUAGE_CODE %} default{% endif %} />
+    {% endfor %}
+    {% blocktrans with firefox="<a href=\"http://www.mozilla.org/\">Firefox</a>" %}Your browser doesn't manage the « video » tag, you should update, e.g. with the last {{ firefox }}.{% endblocktrans %}
+</video>