Browse Source

locales — locale

Artur Paikin 8 years ago
parent
commit
d50518e323
2 changed files with 13 additions and 26 deletions
  1. 7 20
      src/core/Core.js
  2. 6 6
      src/core/Translator.js

+ 7 - 20
src/core/Core.js

@@ -1,10 +1,8 @@
 import Utils from '../core/Utils'
 import Translator from '../core/Translator'
 import ee from 'namespace-emitter'
-// import deepFreeze from 'deep-freeze-strict'
 import UppySocket from './UppySocket'
 import en_US from '../locales/en_US'
-// import throttle from 'throttle-debounce/throttle'
 
 /**
  * Main Uppy core
@@ -15,8 +13,8 @@ export default class Core {
   constructor (opts) {
     // set default options
     const defaultOptions = {
-      // load English as the default locales
-      locales: en_US,
+      // load English as the default locale
+      locale: en_US,
       autoProceed: true,
       debug: false
     }
@@ -24,16 +22,14 @@ export default class Core {
     // Merge default options with the ones set by user
     this.opts = Object.assign({}, defaultOptions, opts)
 
-    // Dictates in what order different plugin types are ran:
-    this.types = [ 'presetter', 'orchestrator', 'progressindicator',
-                    'acquirer', 'modifier', 'uploader', 'presenter', 'debugger']
-
-    this.type = 'core'
+    // // Dictates in what order different plugin types are ran:
+    // this.types = [ 'presetter', 'orchestrator', 'progressindicator',
+    //                 'acquirer', 'modifier', 'uploader', 'presenter', 'debugger']
 
     // Container for different types of plugins
     this.plugins = {}
 
-    this.translator = new Translator({locales: this.opts.locales})
+    this.translator = new Translator({locale: this.opts.locale})
     this.i18n = this.translator.translate.bind(this.translator)
     this.getState = this.getState.bind(this)
     this.updateMeta = this.updateMeta.bind(this)
@@ -61,7 +57,7 @@ export default class Core {
   }
 
   /**
-   * Iterate on all plugins and run `update` on them. Called each time when state changes
+   * Iterate on all plugins and run `update` on them. Called each time state changes
    *
    */
   updateAll (state) {
@@ -83,9 +79,6 @@ export default class Core {
 
     this.state = newState
     this.updateAll(this.state)
-
-    // this.log('Updating state with: ')
-    // this.log(newState)
   }
 
   /**
@@ -439,16 +432,10 @@ export default class Core {
 /**
  * Initializes actions, installs all plugins (by iterating on them and calling `install`), sets options
  *
- * (In the past was used to run a waterfall of runType plugin packs, like so:
- * All preseters(data) --> All acquirers(data) --> All uploaders(data) --> done)
  */
   run () {
     this.log('Core is run, initializing actions, installing plugins...')
 
-    // setInterval(() => {
-    //   this.updateAll(this.state)
-    // }, 1000)
-
     this.actions()
 
     // Forse set `autoProceed` option to false if there are multiple selector Plugins active

+ 6 - 6
src/core/Translator.js

@@ -16,11 +16,11 @@ import en_US from '../locales/en_US'
 export default class Translator {
   constructor (opts) {
     const defaultOptions = {
-      locales: en_US
+      locale: en_US
     }
     this.opts = Object.assign({}, defaultOptions, opts)
-    this.locales = this.opts.locales
-    this.locales.strings = Object.assign({}, en_US.strings, this.opts.locales.strings)
+    this.locale = this.opts.locale
+    this.locale.strings = Object.assign({}, en_US.strings, this.opts.locale.strings)
   }
 
 /**
@@ -66,10 +66,10 @@ export default class Translator {
  */
   translate (key, options) {
     if (options && options.smart_count) {
-      var plural = this.locales.pluralize(options.smart_count)
-      return this.interpolate(this.opts.locales.strings[key][plural], options)
+      var plural = this.locale.pluralize(options.smart_count)
+      return this.interpolate(this.opts.locale.strings[key][plural], options)
     }
 
-    return this.interpolate(this.opts.locales.strings[key], options)
+    return this.interpolate(this.opts.locale.strings[key], options)
   }
 }