Merge pull request #420 from transloadit/chore/s3-translator

s3: Use Translator for localised strings
This commit is contained in:
Artur Paikin 2017-11-13 11:16:48 -05:00 committed by GitHub
commit 0010ca4536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
const Plugin = require('../Plugin')
const Translator = require('../../core/Translator')
const XHRUpload = require('../XHRUpload')
module.exports = class AwsS3 extends Plugin {
@ -23,6 +24,9 @@ module.exports = class AwsS3 extends Plugin {
this.locale = Object.assign({}, defaultLocale, this.opts.locale)
this.locale.strings = Object.assign({}, defaultLocale.strings, this.opts.locale.strings)
this.translator = new Translator({ locale: this.locale })
this.i18n = this.translator.translate.bind(this.translator)
this.prepareUpload = this.prepareUpload.bind(this)
}
@ -43,7 +47,7 @@ module.exports = class AwsS3 extends Plugin {
fileIDs.forEach((id) => {
this.core.emit('core:preprocess-progress', id, {
mode: 'determinate',
message: this.locale.strings.preparingUpload,
message: this.i18n('preparingUpload'),
value: 0
})
})
@ -56,7 +60,7 @@ module.exports = class AwsS3 extends Plugin {
return paramsPromise.then((params) => {
this.core.emit('core:preprocess-progress', file.id, {
mode: 'determinate',
message: this.locale.strings.preparingUpload,
message: this.i18n('preparingUpload'),
value: 1
})
return params