diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-14 17:45:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-14 17:45:02 +0100 |
commit | ad3fa0c56715f98886b1b6400fc54ce7d568d899 (patch) | |
tree | e89a2cafca17a71826fc0e5acd579ae4a8002a26 /client/src/standalone/videos | |
parent | 1506307f2f903ce0f80155072a33345c702b7c76 (diff) | |
download | PeerTube-ad3fa0c56715f98886b1b6400fc54ce7d568d899.tar.gz PeerTube-ad3fa0c56715f98886b1b6400fc54ce7d568d899.tar.zst PeerTube-ad3fa0c56715f98886b1b6400fc54ce7d568d899.zip |
Add missing translations in embed template
Diffstat (limited to 'client/src/standalone/videos')
-rw-r--r-- | client/src/standalone/videos/embed.html | 2 | ||||
-rw-r--r-- | client/src/standalone/videos/embed.ts | 30 |
2 files changed, 19 insertions, 13 deletions
diff --git a/client/src/standalone/videos/embed.html b/client/src/standalone/videos/embed.html index b7cf13ec2..f79cf68df 100644 --- a/client/src/standalone/videos/embed.html +++ b/client/src/standalone/videos/embed.html | |||
@@ -13,7 +13,7 @@ | |||
13 | <body> | 13 | <body> |
14 | 14 | ||
15 | <div id="error-block"> | 15 | <div id="error-block"> |
16 | <h1 id="error-title">Sorry</h1> | 16 | <h1 id="error-title"></h1> |
17 | 17 | ||
18 | <div id="error-content"></div> | 18 | <div id="error-content"></div> |
19 | </div> | 19 | </div> |
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 3a09f285e..54b8fb543 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -192,27 +192,33 @@ class PeerTubeEmbed { | |||
192 | element.parentElement.removeChild(element) | 192 | element.parentElement.removeChild(element) |
193 | } | 193 | } |
194 | 194 | ||
195 | displayError (text: string) { | 195 | displayError (text: string, translations?: { [ id: string ]: string }) { |
196 | // Remove video element | 196 | // Remove video element |
197 | if (this.videoElement) this.removeElement(this.videoElement) | 197 | if (this.videoElement) this.removeElement(this.videoElement) |
198 | 198 | ||
199 | document.title = 'Sorry - ' + text | 199 | const translatedText = peertubeTranslate(text, translations) |
200 | const translatedSorry = peertubeTranslate('Sorry', translations) | ||
201 | |||
202 | document.title = translatedSorry + ' - ' + translatedText | ||
200 | 203 | ||
201 | const errorBlock = document.getElementById('error-block') | 204 | const errorBlock = document.getElementById('error-block') |
202 | errorBlock.style.display = 'flex' | 205 | errorBlock.style.display = 'flex' |
203 | 206 | ||
207 | const errorTitle = document.getElementById('error-title') | ||
208 | errorTitle.innerHTML = peertubeTranslate('Sorry', translations) | ||
209 | |||
204 | const errorText = document.getElementById('error-content') | 210 | const errorText = document.getElementById('error-content') |
205 | errorText.innerHTML = text | 211 | errorText.innerHTML = translatedText |
206 | } | 212 | } |
207 | 213 | ||
208 | videoNotFound () { | 214 | videoNotFound (translations?: { [ id: string ]: string }) { |
209 | const text = 'This video does not exist.' | 215 | const text = 'This video does not exist.' |
210 | this.displayError(text) | 216 | this.displayError(text, translations) |
211 | } | 217 | } |
212 | 218 | ||
213 | videoFetchError () { | 219 | videoFetchError (translations?: { [ id: string ]: string }) { |
214 | const text = 'We cannot fetch the video. Please try again later.' | 220 | const text = 'We cannot fetch the video. Please try again later.' |
215 | this.displayError(text) | 221 | this.displayError(text, translations) |
216 | } | 222 | } |
217 | 223 | ||
218 | getParamToggle (params: URLSearchParams, name: string, defaultValue?: boolean) { | 224 | getParamToggle (params: URLSearchParams, name: string, defaultValue?: boolean) { |
@@ -268,9 +274,9 @@ class PeerTubeEmbed { | |||
268 | ]) | 274 | ]) |
269 | 275 | ||
270 | if (!videoResponse.ok) { | 276 | if (!videoResponse.ok) { |
271 | if (videoResponse.status === 404) return this.videoNotFound() | 277 | if (videoResponse.status === 404) return this.videoNotFound(serverTranslations) |
272 | 278 | ||
273 | return this.videoFetchError() | 279 | return this.videoFetchError(serverTranslations) |
274 | } | 280 | } |
275 | 281 | ||
276 | const videoInfo: VideoDetails = await videoResponse.json() | 282 | const videoInfo: VideoDetails = await videoResponse.json() |
@@ -308,7 +314,7 @@ class PeerTubeEmbed { | |||
308 | 314 | ||
309 | this.playerOptions = videojsOptions | 315 | this.playerOptions = videojsOptions |
310 | this.player = vjs(this.videoContainerId, videojsOptions, () => { | 316 | this.player = vjs(this.videoContainerId, videojsOptions, () => { |
311 | this.player.on('customError', (event: any, data: any) => this.handleError(data.err)) | 317 | this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) |
312 | 318 | ||
313 | window[ 'videojsPlayer' ] = this.player | 319 | window[ 'videojsPlayer' ] = this.player |
314 | 320 | ||
@@ -325,11 +331,11 @@ class PeerTubeEmbed { | |||
325 | }) | 331 | }) |
326 | } | 332 | } |
327 | 333 | ||
328 | private handleError (err: Error) { | 334 | private handleError (err: Error, translations?: { [ id: string ]: string }) { |
329 | if (err.message.indexOf('from xs param') !== -1) { | 335 | if (err.message.indexOf('from xs param') !== -1) { |
330 | this.player.dispose() | 336 | this.player.dispose() |
331 | this.videoElement = null | 337 | this.videoElement = null |
332 | this.displayError('This video is not available because the remote instance is not responding.') | 338 | this.displayError('This video is not available because the remote instance is not responding.', translations) |
333 | return | 339 | return |
334 | } | 340 | } |
335 | } | 341 | } |