From 3fc4bca9e8f08734afb5d79c477b2479b20f02ed Mon Sep 17 00:00:00 2001 From: Danil Valov Date: Thu, 17 Jan 2019 21:02:53 +0600 Subject: [PATCH 1/2] Fix file extensions + add support for `ext` option Fix file extension for `javascript` format and add support of `ext` option for `compileTranslations` --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index acfe66f..a923f60 100644 --- a/index.js +++ b/index.js @@ -20,13 +20,14 @@ function compile(options) { format: options.format }); + const ext = options.format === 'javascript' ? 'js' : options.format; const filePaths = glob.sync(options.input) const outputs = filePaths.map( (filePath) => { const content = fs.readFileSync(filePath, options.encoding || 'utf-8'); const fullFileName = path.basename(filePath); return { content: compiler.convertPo([content]), - fileName: path.basename(filePath, path.extname(fullFileName)) + '.' + options.format + fileName: path.basename(filePath, path.extname(fullFileName)) + '.' + (options.ext || ext) }; } ); From 28fdedd869b1389a9c8e0b6926d51f9b11d47ab6 Mon Sep 17 00:00:00 2001 From: Danil Valov Date: Thu, 17 Jan 2019 21:06:26 +0600 Subject: [PATCH 2/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdea04f..4614bf5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ module.exports = { compileTranslations: { //optional input: 'po/*.po', outputFolder: 'l10n', - format: 'json' + format: 'javascript', // javascript or json + ext: 'js' // optional }, extractStrings: { //optional input: 'app/**/*.html',