Skip to content

Commit

Permalink
Transloadit: move user-facing strings into locale option
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed May 16, 2017
1 parent bfbd60e commit 87a22e7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/plugins/Transloadit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,28 @@ module.exports = class Transloadit extends Plugin {
this.id = 'Transloadit'
this.title = 'Transloadit'

const defaultLocale = {
strings: {
creatingAssembly: 'Preparing upload...',
creatingAssemblyFailed: 'Transloadit: Could not create assembly',
encoding: 'Encoding...'
}
}

const defaultOptions = {
waitForEncoding: false,
waitForMetadata: false,
signature: null,
params: null,
fields: {}
fields: {},
locale: defaultLocale
}

this.opts = Object.assign({}, defaultOptions, opts)

this.locale = Object.assign({}, defaultLocale, this.opts.locale)
this.locale.strings = Object.assign({}, defaultLocale.strings, this.opts.locale.strings)

this.prepareUpload = this.prepareUpload.bind(this)
this.afterUpload = this.afterUpload.bind(this)

Expand Down Expand Up @@ -102,7 +114,7 @@ module.exports = class Transloadit extends Plugin {
}).then(() => {
this.core.log('Transloadit: Created assembly')
}).catch((err) => {
this.core.emit('informer', '⚠️ Transloadit: Could not create assembly', 'error', 0)
this.core.emit('informer', this.opts.locale.strings.creatingAssemblyFailed, 'error', 0)

// Reject the promise.
throw err
Expand Down Expand Up @@ -180,7 +192,7 @@ module.exports = class Transloadit extends Plugin {
}

prepareUpload () {
this.core.emit('informer', '🔄 Preparing upload...', 'info', 0)
this.core.emit('informer', this.opts.locale.strings.creatingAssembly, 'info', 0)
return this.createAssembly().then(() => {
this.core.emit('informer:hide')
})
Expand All @@ -194,7 +206,7 @@ module.exports = class Transloadit extends Plugin {
return
}

this.core.emit('informer', '🔄 Encoding...', 'info', 0)
this.core.emit('informer', this.opts.locale.strings.encoding, 'info', 0)
return this.assemblyReady.then(() => {
return this.client.getAssemblyStatus(this.state.assembly.status_endpoint)
}).then((assembly) => {
Expand Down

1 comment on commit 87a22e7

@kvz
Copy link
Member

@kvz kvz commented on 87a22e7 May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Please sign in to comment.