lib/index.js
function createLocales (json, params, callback) {
  var locales = registerLocales(json.shift());
  var indexes = locales.indexes;
  var messageName;

  delete locales.indexes;

  json.forEach(function (messageLine) {
    var messageProp, lineValue, propPath;

    for (var i = 0, len = messageLine.length; i < len; i++) {
      lineValue = messageLine[i];
      if (i === 0) {
        // The first item is a message name
        // or an empty string for a "description"
        messageName = lineValue || messageName;

      } else if (i === 1) {
        // The second is "message" or "description"
        messageProp = lineValue;

      } else {
        // All others are locales
        if (lineValue === '' && messageProp !== 'description') {
          continue;
        }
        propPath = [
          indexes[i], 'messages', messageName
        ].join('.');
        getByPath(locales, propPath, true)[messageProp] =
          messageProp !== 'placeholders' ?
            lineValue || ''
            : parsePlaceholders(lineValue);
      }
    }
  });
  if (params.debug) {
    log('Generated locales:', locales);
  }
  writeLocales(locales, params, callback);
}
function createLocales (json, params, callback) {
  var locales = registerLocales(json.shift());
  var indexes = locales.indexes;
  var messageName;

  delete locales.indexes;

  json.forEach(function (messageLine) {
    var messageProp, lineValue, propPath;

    for (var i = 0, len = messageLine.length; i < len; i++) {
      lineValue = messageLine[i];
      if (i === 0) {
        // The first item is a message name
        // or an empty string for a "description"
        messageName = lineValue || messageName;

      } else if (i === 1) {
        // The second is "message" or "description"
        messageProp = lineValue;

      } else {
        // All others are locales
        if (lineValue === '' && messageProp !== 'description') {
          continue;
        }
        propPath = [
          indexes[i], 'messages', messageName
        ].join('.');
        getByPath(locales, propPath, true)[messageProp] =
          messageProp !== 'placeholders' ?
            lineValue || ''
            : parsePlaceholders(lineValue);
      }
    }
  });
  if (params.debug) {
    log('Generated locales:', locales);
  }
  writeLocales(locales, params, callback);
}
function createLocales ( json , params , callback ) { var locales = registerLocales ( json . shift ( ) ) ; var indexes = locales . indexes ; var messageName ; delete locales . indexes ; json . forEach ( function ( messageLine ) { var messageProp , lineValue , propPath ; for ( var i = 0 , len = messageLine . length ; i < len ; i ++ ) { lineValue = messageLine [ i ] ; if ( i === 0 ) { // The first item is a message name // or an empty string for a "description" messageName = lineValue || messageName ; } else if ( i === 1 ) { // The second is "message" or "description" messageProp = lineValue ; } else { // All others are locales if ( lineValue === '' && messageProp !== 'description' ) { continue ; } propPath = [ indexes [ i ] , 'messages' , messageName ] . join ( '.' ) ; getByPath ( locales , propPath , true ) [ messageProp ] = messageProp !== 'placeholders' ? lineValue || '' : parsePlaceholders ( lineValue ) ; } } } ) ; if ( params . debug ) { log ( 'Generated locales:' , locales ) ; } writeLocales ( locales , params , callback ) ; }
Creates all directories and files from json
@param {Array} json
@param {object} params
@param {function} callback
Creates all directories and files from json