aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-09 13:21:33 +0200
committerChocobozzz <me@florianbigard.com>2021-04-09 13:23:25 +0200
commitc713017f3cd2d617da22c24c579342ec4121cfcd (patch)
tree4f23d24442a177f5e71e7b2c9e66b5cd5fba121c /client/src/app/core/plugins
parent32d13b203b3abf756e751994836c28ddd1f4ebd9 (diff)
downloadPeerTube-c713017f3cd2d617da22c24c579342ec4121cfcd.tar.gz
PeerTube-c713017f3cd2d617da22c24c579342ec4121cfcd.tar.zst
PeerTube-c713017f3cd2d617da22c24c579342ec4121cfcd.zip
Translate plugin options
Diffstat (limited to 'client/src/app/core/plugins')
-rw-r--r--client/src/app/core/plugins/plugin.service.ts20
1 files changed, 19 insertions, 1 deletions
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index 54dba5e17..c2dcf9fef 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -46,7 +46,10 @@ export class PluginService implements ClientHook {
46 customModal: CustomModalComponent 46 customModal: CustomModalComponent
47 47
48 private plugins: ServerConfigPlugin[] = [] 48 private plugins: ServerConfigPlugin[] = []
49 private helpers: { [ npmName: string ]: RegisterClientHelpers } = {}
50
49 private scopes: { [ scopeName: string ]: PluginInfo[] } = {} 51 private scopes: { [ scopeName: string ]: PluginInfo[] } = {}
52
50 private loadedScripts: { [ script: string ]: boolean } = {} 53 private loadedScripts: { [ script: string ]: boolean } = {}
51 private loadedScopes: PluginClientScope[] = [] 54 private loadedScopes: PluginClientScope[] = []
52 private loadingScopes: { [id in PluginClientScope]?: boolean } = {} 55 private loadingScopes: { [id in PluginClientScope]?: boolean } = {}
@@ -197,13 +200,28 @@ export class PluginService implements ClientHook {
197 return this.formFields.video.filter(f => f.videoFormOptions.type === type) 200 return this.formFields.video.filter(f => f.videoFormOptions.type === type)
198 } 201 }
199 202
203 translateBy (npmName: string, toTranslate: string) {
204 const helpers = this.helpers[npmName]
205 if (!helpers) {
206 console.error('Unknown helpers to translate %s from %s.', toTranslate, npmName)
207 return toTranslate
208 }
209
210 return helpers.translate(toTranslate)
211 }
212
200 private loadPlugin (pluginInfo: PluginInfo) { 213 private loadPlugin (pluginInfo: PluginInfo) {
201 return this.zone.runOutsideAngular(() => { 214 return this.zone.runOutsideAngular(() => {
215 const npmName = this.nameToNpmName(pluginInfo.plugin.name, pluginInfo.pluginType)
216
217 const helpers = this.buildPeerTubeHelpers(pluginInfo)
218 this.helpers[npmName] = helpers
219
202 return loadPlugin({ 220 return loadPlugin({
203 hooks: this.hooks, 221 hooks: this.hooks,
204 formFields: this.formFields, 222 formFields: this.formFields,
205 pluginInfo, 223 pluginInfo,
206 peertubeHelpersFactory: pluginInfo => this.buildPeerTubeHelpers(pluginInfo) 224 peertubeHelpersFactory: () => helpers
207 }) 225 })
208 }) 226 })
209 } 227 }