react-intl-po
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -7,2 +7,13 @@ # react-intl-po | ||
## [v2.2.1] | ||
> April 11, 2018 | ||
* feat: Support --indentation option ([@matheusd](https://github.com/matheusd) in [#128]) | ||
* chore: ncu update & use node 9.11.1 | ||
## [v2.2.0] | ||
> March 13, 2018 | ||
* feat: Custom lang mapper regex and index ([@camflan](https://github.com/camflan) in [#122]) | ||
@@ -9,0 +20,0 @@ * chore: ncu update & upgrade node 9.8.0 and yarn 1.5.1 |
@@ -10,6 +10,11 @@ #!/usr/bin/env node | ||
var numberOrChars = function numberOrChars(s) { | ||
return (/^\d+$/.test(s) ? parseInt(s, 10) : s | ||
); | ||
}; | ||
_commander2.default.command('json2pot <srcPatterns>').option('-o, --output <path>', 'The output pathname of `.pot` file to be translated').option('-k, --message-key [key]', 'Translation message key (default key is `defaultMessage`)').option('-c, --message-context [context]', 'Translation message context (defaults to no context)').action(require('./extractAndWritePOTFromMessagesSync')); | ||
_commander2.default.command('po2json <srcPatterns>').option('-m, --messages-pattern <path>', 'The pattern of *json* files extracted from *babel-plugin-react-intl*').option('-o, --output <path>', 'The output pathname of a file / directory').option('-k, --message-key [key]', 'Translation message key (default key is `defaultMessage`)').option('-c, --message-context [context]', 'Translation message context (defaults to no context)').option('-l, --lang-mapper-pattern <pattern>', 'Custom regex to use for lang mapping.').option('-i, --lang-mapper-pattern-index [index]', 'When specifying a custom lang-mapper-pattern, the index of match to use for the lang mapping. Default is 1, index is ignored if not using a custom lang mapping regex').action(require('./filterPOAndWriteTranslateSync')); | ||
_commander2.default.command('po2json <srcPatterns>').option('-m, --messages-pattern <path>', 'The pattern of *json* files extracted from *babel-plugin-react-intl*').option('-o, --output <path>', 'The output pathname of a file / directory').option('-k, --message-key [key]', 'Translation message key (default key is `defaultMessage`)').option('-c, --message-context [context]', 'Translation message context (defaults to no context)').option('-l, --lang-mapper-pattern <pattern>', 'Custom regex to use for lang mapping.').option('-i, --lang-mapper-pattern-index [index]', 'When specifying a custom lang-mapper-pattern, the index of match to use for the lang mapping. Default is 1, index is ignored if not using a custom lang mapping regex').option('--indentation <number|characters>', 'Number of spaces or characters to use for indenting (adding space) to the output json entries.', numberOrChars).action(require('./filterPOAndWriteTranslateSync')); | ||
_commander2.default.parse(process.argv); |
@@ -67,3 +67,4 @@ 'use strict'; | ||
langMapperPatternIndex = _ref.langMapperPatternIndex, | ||
output = _ref.output; | ||
output = _ref.output, | ||
indentation = _ref.indentation; | ||
@@ -103,3 +104,3 @@ var placeholder = R.pipe(_readAllMessageAsObjectSync2.default, | ||
_mkdirp2.default.sync(_path2.default.dirname(output)); // ensure the output folder exists | ||
_fs2.default.writeFileSync(output, JSON.stringify(result, null, 0)); | ||
_fs2.default.writeFileSync(output, JSON.stringify(result, null, indentation)); | ||
console.log(_chalk2.default.green('> [react-intl-po] write file -> ' + output + ' \u2714\uFE0F\n')); | ||
@@ -110,3 +111,3 @@ } else { | ||
Object.keys(result).forEach(function (lang) { | ||
_fs2.default.writeFileSync(_path2.default.join(output, lang + '.json'), JSON.stringify(result[lang], null, 0)); | ||
_fs2.default.writeFileSync(_path2.default.join(output, lang + '.json'), JSON.stringify(result[lang], null, indentation)); | ||
console.log(_chalk2.default.green('> [react-intl-po] write file -> ' + _path2.default.join(output, lang + '.json') + ' \u2714\uFE0F')); | ||
@@ -113,0 +114,0 @@ }); |
{ | ||
"name": "react-intl-po", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Extract POT from react-intl and convert back to json.", | ||
@@ -45,8 +45,8 @@ "author": "Michael Hsu", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-import": "2.9.0", | ||
"eslint-plugin-jest": "21.14.0", | ||
"eslint-plugin-import": "2.10.0", | ||
"eslint-plugin-jest": "21.15.0", | ||
"eslint-plugin-prettier": "2.6.0", | ||
"husky": "0.14.3", | ||
"jest": "22.4.2", | ||
"lint-staged": "7.0.0", | ||
"lint-staged": "7.0.4", | ||
"prettier": "1.11.1" | ||
@@ -94,3 +94,3 @@ }, | ||
"chalk": "^2.3.2", | ||
"commander": "^2.15.0", | ||
"commander": "^2.15.1", | ||
"glob": "^7.1.2", | ||
@@ -97,0 +97,0 @@ "mkdirp": "^0.5.1", |
@@ -84,2 +84,3 @@ # react-intl-po | ||
| `-i, --lang-mapper-pattern-index [index]` | [Optional] When specifying a custom lang-mapper-pattern, the index of match to use for the lang mapping. Default is 1, index is ignored if not using a custom lang mapping regex. [PR#122](https://github.com/evenchange4/react-intl-po/pull/122) | | ||
| `--indentation <number|char>` | [Optional] Specify a number of spaces or a set of characters to be used before each entry of the resulting json file. Defaults to `null`, which means the entries are not prefixed with spaces. | | ||
@@ -148,3 +149,3 @@ ## Property | ||
* node >= 9.8.0 | ||
* node >= 9.11.1 | ||
* yarn >= 1.5.1 | ||
@@ -151,0 +152,0 @@ |
@@ -5,2 +5,4 @@ #!/usr/bin/env node | ||
const numberOrChars = s => (/^\d+$/.test(s) ? parseInt(s, 10) : s); | ||
program | ||
@@ -45,4 +47,9 @@ .command('json2pot <srcPatterns>') | ||
) | ||
.option( | ||
'--indentation <number|characters>', | ||
'Number of spaces or characters to use for indenting (adding space) to the output json entries.', | ||
numberOrChars, | ||
) | ||
.action(require('./filterPOAndWriteTranslateSync')); | ||
program.parse(process.argv); |
@@ -28,2 +28,3 @@ /* eslint-disable no-console */ | ||
output, | ||
indentation, | ||
}, | ||
@@ -70,3 +71,3 @@ ) { | ||
mkdirp.sync(path.dirname(output)); // ensure the output folder exists | ||
fs.writeFileSync(output, JSON.stringify(result, null, 0)); | ||
fs.writeFileSync(output, JSON.stringify(result, null, indentation)); | ||
console.log(chalk.green(`> [react-intl-po] write file -> ${output} ✔️\n`)); | ||
@@ -79,3 +80,3 @@ } else { | ||
path.join(output, `${lang}.json`), | ||
JSON.stringify(result[lang], null, 0), | ||
JSON.stringify(result[lang], null, indentation), | ||
); | ||
@@ -82,0 +83,0 @@ console.log( |
@@ -78,1 +78,27 @@ import fs from 'fs'; | ||
}); | ||
it('should output json file with spaces if indentation number is used', () => { | ||
const messagesPattern = './test/messages/**/*.json'; | ||
const output = './test/temp/translations-defaultMessage-indent4.json'; | ||
const indentation = 4; | ||
filterPOAndWriteTranslateSync('./test/po/mcs-public.*.po', { | ||
messagesPattern, | ||
output, | ||
indentation, | ||
}); | ||
expect(fs.readFileSync(output, 'utf8')).toMatchSnapshot(); | ||
}); | ||
it('should output json file with prefix char if indentation char is used', () => { | ||
const messagesPattern = './test/messages/**/*.json'; | ||
const output = './test/temp/translations-defaultMessage-indentchar.json'; | ||
const indentation = '\t\t'; | ||
filterPOAndWriteTranslateSync('./test/po/mcs-public.*.po', { | ||
messagesPattern, | ||
output, | ||
indentation, | ||
}); | ||
expect(fs.readFileSync(output, 'utf8')).toMatchSnapshot(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86467
59
1164
199
Updatedcommander@^2.15.1