Mercurial > sat_legacy_website
diff sat_website/media.py @ 93:9ae3d9c8b28a
actually display the subtitles (with Firefox it is used only when it's the first <track /> of the list, and when the "default" option is present)
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 16 Jun 2015 21:26:58 +0200 |
parents | 7a79cb5ed43b |
children | 14080acdf896 |
line wrap: on
line diff
--- a/sat_website/media.py Tue Jun 16 20:31:16 2015 +0200 +++ b/sat_website/media.py Tue Jun 16 21:26:58 2015 +0200 @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. """ -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import get_language, ugettext_lazy as _ from django.conf import settings from collections import namedtuple, OrderedDict import os.path @@ -29,11 +29,17 @@ class VideoDesc(namedtuple("VideoDesc", "paths description poster data")): @property def subtitles(self): - key = _(u"subtitles") + key = "subtitles" if key not in self.data: return {} result = OrderedDict() - for lang in self.data[key]: + + # put the current lang first + current_lang = get_language() + langs = [current_lang] if current_lang in self.data[key] else [] + langs.extend([lang for lang in self.data[key] if lang != current_lang]) + + for lang in langs: try: result[lang] = os.path.splitext(self.paths[lang])[0] + '.vtt' except IndexError: @@ -53,7 +59,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"subtitles"): ["en", "fr"]}), + {_(u"version"): "0.5", _(u"year"): "2015", "subtitles": ["en", "fr"]}), ImageDesc("images/screenshots/0.5/overview_libervia.png", _(u"Overview"), {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}),