Przeglądaj źródła

s3: Use Translator for localised strings

Renée Kooi 7 lat temu
rodzic
commit
06ba8adf50
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      src/plugins/AwsS3/index.js

+ 6 - 2
src/plugins/AwsS3/index.js

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