+
+ private buildPeerTubeHelpers (pluginInfo: PluginInfo): RegisterClientHelpers {
+ const { plugin } = pluginInfo
+ const npmName = this.nameToNpmName(pluginInfo.plugin.name, pluginInfo.pluginType)
+
+ return {
+ getBaseStaticRoute: () => {
+ const pathPrefix = this.getPluginPathPrefix(pluginInfo.isTheme)
+ return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/static`
+ },
+
+ getSettings: () => {
+ const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
+
+ return this.authHttp.get<PublicServerSetting>(path)
+ .pipe(
+ map(p => p.publicSettings),
+ catchError(res => this.restExtractor.handleError(res))
+ )
+ .toPromise()
+ },
+
+ isLoggedIn: () => {
+ return this.authService.isLoggedIn()
+ },
+
+ translate: (value: string) => {
+ return this.translationsObservable
+ .pipe(map(allTranslations => allTranslations[npmName]))
+ .pipe(map(translations => peertubeTranslate(value, translations)))
+ .toPromise()
+ }
+ }
+ }
+
+ private loadTranslations () {
+ const completeLocale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
+
+ // Default locale, nothing to translate
+ if (isDefaultLocale(completeLocale)) this.translationsObservable = of({}).pipe(shareReplay())
+
+ this.translationsObservable = this.authHttp
+ .get<PluginTranslation>(PluginService.BASE_PLUGIN_URL + '/translations/' + completeLocale + '.json')
+ .pipe(shareReplay())
+ }
+
+ private getPluginPathPrefix (isTheme: boolean) {
+ return isTheme ? '/themes' : '/plugins'
+ }