Skip to content

Commit

Permalink
Merge pull request #158 from Claymore1337/i18nFix
Browse files Browse the repository at this point in the history
fix:I18n fix
  • Loading branch information
trieloff authored Jul 31, 2019
2 parents 981f1b0 + 5e37d2d commit 5a916a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
15 changes: 14 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)));
}
Expand All @@ -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()) {
Expand Down
13 changes: 0 additions & 13 deletions lib/markdownWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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=consoleArgs.i ;
} else {
i18nPath=__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
Expand Down
8 changes: 0 additions & 8 deletions lib/readmeWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ],
Expand Down

0 comments on commit 5a916a8

Please sign in to comment.