From 3dfa84940273619ae00f11a5f419a5e4876b2f53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Aug 2018 10:48:35 +0200 Subject: Translate subtitle langs in player --- client/src/standalone/videos/embed.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 2aabb5fe8..ea3436c7c 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -20,8 +20,8 @@ import 'whatwg-fetch' import * as vjs from 'video.js' import * as Channel from 'jschannel' -import { ResultList, VideoDetails } from '../../../../shared' -import { addContextMenu, getVideojsOptions, loadLocale } from '../../assets/player/peertube-player' +import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' +import { addContextMenu, getServerTranslations, getVideojsOptions, loadLocaleInVideoJS } from '../../assets/player/peertube-player' import { PeerTubeResolution } from '../player/definitions' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' @@ -257,8 +257,9 @@ class PeerTubeEmbed { const lastPart = urlParts[ urlParts.length - 1 ] const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ] - await loadLocale(window.location.origin, vjs, navigator.language) - const [ videoResponse, captionsResponse ] = await Promise.all([ + const [ , serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ + loadLocaleInVideoJS(window.location.origin, vjs, navigator.language), + getServerTranslations(window.location.origin, navigator.language), this.loadVideoInfo(videoId), this.loadVideoCaptions(videoId) ]) @@ -274,7 +275,7 @@ class PeerTubeEmbed { if (captionsResponse.ok) { const { data } = (await captionsResponse.json()) as ResultList videoCaptions = data.map(c => ({ - label: c.language.label, + label: peertubeTranslate(c.language.label, serverTranslations), language: c.language.id, src: window.location.origin + c.captionPath })) -- cgit v1.2.3