aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-16 11:39:58 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit5d128505dca854cb7225624936d1053f06473260 (patch)
tree52a1a5d91412d6f0c314509ed0e98b51b65dd2c2 /client/src
parentd03cd8bb206efcaa3fa6899ce82f5b1838a9f46f (diff)
downloadPeerTube-5d128505dca854cb7225624936d1053f06473260.tar.gz
PeerTube-5d128505dca854cb7225624936d1053f06473260.tar.zst
PeerTube-5d128505dca854cb7225624936d1053f06473260.zip
Cache player translations
Diffstat (limited to 'client/src')
-rw-r--r--client/src/assets/player/peertube-player.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
index 0b9303a73..7e53d2142 100644
--- a/client/src/assets/player/peertube-player.ts
+++ b/client/src/assets/player/peertube-player.ts
@@ -184,11 +184,24 @@ function loadLocaleInVideoJS (serverUrl: string, videojs: any, locale: string) {
184 // It is the default locale, nothing to translate 184 // It is the default locale, nothing to translate
185 if (!path) return Promise.resolve(undefined) 185 if (!path) return Promise.resolve(undefined)
186 186
187 const completeLocale = getCompleteLocale(locale) 187 let p: Promise<any>
188
189 if (loadLocaleInVideoJS.cache[path]) {
190 p = Promise.resolve(loadLocaleInVideoJS.cache[path])
191 } else {
192 p = fetch(path + '/player.json')
193 .then(res => res.json())
194 .then(json => {
195 loadLocaleInVideoJS.cache[path] = json
196 return json
197 })
198 }
188 199
189 return fetch(path + '/player.json') 200 const completeLocale = getCompleteLocale(locale)
190 .then(res => res.json()) 201 return p.then(json => videojs.addLanguage(getShortLocale(completeLocale), json))
191 .then(json => videojs.addLanguage(getShortLocale(completeLocale), json)) 202}
203namespace loadLocaleInVideoJS {
204 export const cache: { [ path: string ]: any } = {}
192} 205}
193 206
194function getServerTranslations (serverUrl: string, locale: string) { 207function getServerTranslations (serverUrl: string, locale: string) {