From 74b7c6d48e9ca377fe938c8134ed74b612e62ba0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Jun 2018 17:37:13 +0200 Subject: Little i18n refractoring --- client/src/assets/player/peertube-player.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'client/src/assets/player') diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index b604097fa..9e37b75d2 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -12,7 +12,7 @@ import './peertube-videojs-plugin' import './peertube-load-progress-bar' import { videojsUntyped } from './peertube-videojs-typings' import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' -import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' +import { getCompleteLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' @@ -141,11 +141,13 @@ function addContextMenu (player: any, videoEmbedUrl: string) { } function loadLocale (serverUrl: string, videojs: any, locale: string) { - if (!is18nLocale(locale) || isDefaultLocale(locale)) return undefined + const completeLocale = getCompleteLocale(locale) - return fetch(serverUrl + '/client/locales/' + locale + '/player.json') + if (!is18nLocale(completeLocale) || isDefaultLocale(completeLocale)) return Promise.resolve(undefined) + + return fetch(serverUrl + '/client/locales/' + completeLocale + '/player.json') .then(res => res.json()) - .then(json => videojs.addLanguage(locale, json)) + .then(json => videojs.addLanguage(completeLocale, json)) } export { -- cgit v1.2.3