aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player.ts')
-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) {