index.js
function load(options) {
  if (cache[options.locales]) {
    options.verbose && gutil.log('Skip loading cached translations from', options.locales);
    return dictionaries = cache[options.locales];
  }
  try {
    options.verbose && gutil.log('Loading translations from', options.locales);
    var files = fs.readdirSync(options.locales);
    var count = 0;
    for (var i in files) {
      var file = files[i];
      switch (path.extname(file)) {
        case '.json':
        case '.js':
          dictionaries[path.basename(file, path.extname(file))] = flat(require(path.join(process.cwd(), options.locales, file)));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.ini':
          var iniData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = flat(ini2json(iniData));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.csv':
          var csvData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = csv2json(csvData);
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        default:
          options.verbose && gutil.log('Ignored file', file);
      }
    }
    options.verbose && gutil.log('Loaded', count,  'translations from', options.locales);
    if (options.cache) {
      options.verbose && gutil.log('Cashing translations from', options.locales);
      cache[options.locales] = dictionaries;
    }
  } catch (e) {
    e.message = 'No translation dictionaries have been found!';
    throw e;
  }
}
function load(options) {
  if (cache[options.locales]) {
    options.verbose && gutil.log('Skip loading cached translations from', options.locales);
    return dictionaries = cache[options.locales];
  }
  try {
    options.verbose && gutil.log('Loading translations from', options.locales);
    var files = fs.readdirSync(options.locales);
    var count = 0;
    for (var i in files) {
      var file = files[i];
      switch (path.extname(file)) {
        case '.json':
        case '.js':
          dictionaries[path.basename(file, path.extname(file))] = flat(require(path.join(process.cwd(), options.locales, file)));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.ini':
          var iniData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = flat(ini2json(iniData));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.csv':
          var csvData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = csv2json(csvData);
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        default:
          options.verbose && gutil.log('Ignored file', file);
      }
    }
    options.verbose && gutil.log('Loaded', count,  'translations from', options.locales);
    if (options.cache) {
      options.verbose && gutil.log('Cashing translations from', options.locales);
      cache[options.locales] = dictionaries;
    }
  } catch (e) {
    e.message = 'No translation dictionaries have been found!';
    throw e;
  }
}
function load ( options ) { if ( cache [ options . locales ] ) { options . verbose && gutil . log ( 'Skip loading cached translations from' , options . locales ) ; return dictionaries = cache [ options . locales ] ; } try { options . verbose && gutil . log ( 'Loading translations from' , options . locales ) ; var files = fs . readdirSync ( options . locales ) ; var count = 0 ; for ( var i in files ) { var file = files [ i ] ; switch ( path . extname ( file ) ) { case '.json' : case '.js' : dictionaries [ path . basename ( file , path . extname ( file ) ) ] = flat ( require ( path . join ( process . cwd ( ) , options . locales , file ) ) ) ; options . verbose && gutil . log ( 'Added translations from' , file ) ; count ++ ; break ; case '.ini' : var iniData = fs . readFileSync ( path . join ( process . cwd ( ) , options . locales , file ) ) ; dictionaries [ path . basename ( file , path . extname ( file ) ) ] = flat ( ini2json ( iniData ) ) ; options . verbose && gutil . log ( 'Added translations from' , file ) ; count ++ ; break ; case '.csv' : var csvData = fs . readFileSync ( path . join ( process . cwd ( ) , options . locales , file ) ) ; dictionaries [ path . basename ( file , path . extname ( file ) ) ] = csv2json ( csvData ) ; options . verbose && gutil . log ( 'Added translations from' , file ) ; count ++ ; break ; default : options . verbose && gutil . log ( 'Ignored file' , file ) ; } } options . verbose && gutil . log ( 'Loaded' , count , 'translations from' , options . locales ) ; if ( options . cache ) { options . verbose && gutil . log ( 'Cashing translations from' , options . locales ) ; cache [ options . locales ] = dictionaries ; } } catch ( e ) { e . message = 'No translation dictionaries have been found!' ; throw e ; } }
Loads the dictionaries from the locale directory.
@param {Object} options
Loads the dictionaries from the locale directory .