Skip to content
Snippets Groups Projects
Commit 5e37d2de authored by COMLINE\Kunz's avatar COMLINE\Kunz
Browse files

fix(i18n init): moved the i18n init part to the cli.js

there was an bug in the init part of the i18n setup. It was moved to the cli to handle it in the
same way

fix #157
parent 5fe7db27
Branches
Tags
No related merge requests found
......@@ -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()) {
......
......@@ -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
......
......@@ -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,
......
......@@ -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' ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment