diff --git a/cli.js b/cli.js index a8eb90c3..a546f761 100755 --- a/cli.js +++ b/cli.js @@ -54,6 +54,7 @@ var argv = require('optimist') .argv; const docs = _.fromPairs(_.toPairs(argv).filter(([ key, value ]) => { return key.startsWith('link-'); }).map(([ key, value ]) => { return [ key.substr(5), value ];})); +const i18n = require('i18n'); const logger = winston.createLogger({ level: 'info', @@ -82,7 +83,6 @@ var schemaDir = argv.x === '-' ? '' : argv.x ? path.resolve(argv.x) : outDir; var target = fs.statSync(schemaPath); const readme = argv.n !== true; const schemaExtension = argv.e || 'schema.json'; - if (argv.s){ ajv.addMetaSchema(require(path.resolve(argv.s))); } @@ -102,6 +102,19 @@ if (argv.m) { } } } +let i18nPath; +if (argv !== undefined && argv.i !== undefined){ + i18nPath=path.resolve(argv.i) ; +} else { + i18nPath=path.resolve(path.join(__dirname, 'lib/locales')); +} +i18n.configure({ + // setup some locales - other locales default to en silently + locales:[ 'en' ], + // where to store json files - defaults to './locales' relative to modules directory + directory: i18nPath, + defaultLocale: 'en' +}); logger.info('output directory: %s', outDir); if (target.isDirectory()) { diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index 52d97fae..42df15b3 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -171,20 +171,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen }; outDir = outDir ? outDir : path.resolve(path.join('.', 'out')); - let i18nPath; - if (consoleArgs !== undefined && consoleArgs.i !== undefined){ - i18nPath=path.resolve(consoleArgs.i) ; - } else { - i18nPath=path.resolve(path.join(__dirname, 'locales')); - } console.log(filename); - i18n.configure({ - // setup some locales - other locales default to en silently - locales:[ 'en' ], - // where to store json files - defaults to './locales' relative to modules directory - directory: i18nPath, - defaultLocale: 'en' - }); //console.log(dependencyMap); // this structure allows us to have separate templates for each element. Instead of having // one huge template, each block can be built individually diff --git a/lib/readmeWriter.js b/lib/readmeWriter.js index acf4641e..2d40abe1 100644 --- a/lib/readmeWriter.js +++ b/lib/readmeWriter.js @@ -35,14 +35,6 @@ function directory(full, base) { * @param {string} base - schema base directory */ const generateReadme = function(paths, schemas, out, base) { - let i18nPath=path.resolve('./lib/locales'); - i18n.configure({ - // setup some locales - other locales default to en silently - locales:[ 'en' ], - // where to store json files - defaults to './locales' relative to modules directory - directory: i18nPath, - defaultLocale: 'en' - }); const coreinfo = _.values(schemas).map(schema => { return { id: schema.jsonSchema.$id, diff --git a/spec/lib/header.spec.js b/spec/lib/header.spec.js index c253f401..0fcd8348 100644 --- a/spec/lib/header.spec.js +++ b/spec/lib/header.spec.js @@ -7,7 +7,7 @@ beforeEach(function() { colors: true, inline: true })); - let i18nPath=path.resolve('./lib/locales'); + let i18nPath=path.resolve(path.join(__dirname, '../../lib/locales')); i18n.configure({ // setup some locales - other locales default to en silently locales:[ 'en' ],