Bläddra i källkod

Merge pull request #666 from transloadit/fix/merge-core-locales

Fix merging locale strings in Core.
Artur Paikin 7 år sedan
förälder
incheckning
6b8df5aab7
2 ändrade filer med 15 tillägg och 2 borttagningar
  1. 0 2
      src/core/Core.js
  2. 15 0
      src/core/Core.test.js

+ 0 - 2
src/core/Core.js

@@ -63,8 +63,6 @@ class Uppy {
     // Container for different types of plugins
     // Container for different types of plugins
     this.plugins = {}
     this.plugins = {}
 
 
-    this.translator = new Translator({locale: this.opts.locale})
-    this.i18n = this.translator.translate.bind(this.translator)
     this.getState = this.getState.bind(this)
     this.getState = this.getState.bind(this)
     this.getPlugin = this.getPlugin.bind(this)
     this.getPlugin = this.getPlugin.bind(this)
     this.setFileMeta = this.setFileMeta.bind(this)
     this.setFileMeta = this.setFileMeta.bind(this)

+ 15 - 0
src/core/Core.test.js

@@ -1187,4 +1187,19 @@ describe('src/Core', () => {
       })
       })
     })
     })
   })
   })
+
+  describe('i18n', () => {
+    it('merges in custom locale strings', () => {
+      const core = new Core({
+        locale: {
+          strings: {
+            test: 'beep boop'
+          }
+        }
+      })
+
+      expect(core.i18n('exceedsSize')).toBe('This file exceeds maximum allowed size of')
+      expect(core.i18n('test')).toBe('beep boop')
+    })
+  })
 })
 })