react-intl-po
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -7,2 +7,9 @@ # react-intl-po | ||
## [v2.2.2] | ||
> April 30, 2018 | ||
* feat: Add sort-by-id option to po2json([@matheusd](https://github.com/matheusd) in [#134]) | ||
* chore: ncu update | ||
## [v2.2.1] | ||
@@ -9,0 +16,0 @@ |
@@ -17,4 +17,4 @@ #!/usr/bin/env node | ||
_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.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).option('--sort-by-id', 'If specified, the entries of each language are sorted by id before being output').action(require('./filterPOAndWriteTranslateSync')); | ||
_commander2.default.parse(process.argv); |
@@ -68,4 +68,7 @@ 'use strict'; | ||
output = _ref.output, | ||
indentation = _ref.indentation; | ||
indentation = _ref.indentation, | ||
sortById = _ref.sortById; | ||
var sort = sortById ? R.sortBy(R.prop('id')) : R.identity; | ||
var placeholder = R.pipe(_readAllMessageAsObjectSync2.default, | ||
@@ -77,3 +80,3 @@ // 1. Object { messagekey: { messageContext: [[] , []] } } | ||
// 3. Array [[], []] | ||
R.flatten, | ||
R.flatten, sort, | ||
// 4. Array [] | ||
@@ -80,0 +83,0 @@ R.indexBy(R.prop('id')), |
{ | ||
"name": "react-intl-po", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Extract POT from react-intl and convert back to json.", | ||
@@ -37,17 +37,17 @@ "author": "Michael Hsu", | ||
"babel-cli": "6.26.0", | ||
"babel-eslint": "8.2.2", | ||
"babel-eslint": "8.2.3", | ||
"babel-plugin-add-module-exports": "0.2.1", | ||
"babel-preset-es2015": "6.24.1", | ||
"babel-preset-stage-0": "6.24.1", | ||
"codecov": "3.0.0", | ||
"eslint": "4.18.2", | ||
"codecov": "3.0.1", | ||
"eslint": "4.19.1", | ||
"eslint-config-airbnb-base": "12.1.0", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-import": "2.10.0", | ||
"eslint-plugin-jest": "21.15.0", | ||
"eslint-plugin-import": "2.11.0", | ||
"eslint-plugin-jest": "21.15.1", | ||
"eslint-plugin-prettier": "2.6.0", | ||
"husky": "0.14.3", | ||
"jest": "22.4.2", | ||
"lint-staged": "7.0.4", | ||
"prettier": "1.11.1" | ||
"jest": "22.4.3", | ||
"lint-staged": "7.0.5", | ||
"prettier": "1.12.1" | ||
}, | ||
@@ -54,0 +54,0 @@ "babel": { |
@@ -84,3 +84,4 @@ # 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. | | ||
| `--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. | | ||
| `--sort-by-id` | [Optional] If specified, the entries of each language are sorted by id before being output | | ||
@@ -87,0 +88,0 @@ ## Property |
@@ -51,4 +51,8 @@ #!/usr/bin/env node | ||
) | ||
.option( | ||
'--sort-by-id', | ||
'If specified, the entries of each language are sorted by id before being output', | ||
) | ||
.action(require('./filterPOAndWriteTranslateSync')); | ||
program.parse(process.argv); |
@@ -29,4 +29,7 @@ /* eslint-disable no-console */ | ||
indentation, | ||
sortById, | ||
}, | ||
) { | ||
const sort = sortById ? R.sortBy(R.prop('id')) : R.identity; | ||
const placeholder = R.pipe( | ||
@@ -40,2 +43,3 @@ readAllMessageAsObjectSync, | ||
R.flatten, | ||
sort, | ||
// 4. Array [] | ||
@@ -42,0 +46,0 @@ R.indexBy(R.prop('id')), |
@@ -104,1 +104,14 @@ import fs from 'fs'; | ||
}); | ||
it('should output sorted file if sortById is used', () => { | ||
const messagesPattern = './test/messages/**/*.json'; | ||
const output = './test/temp/translations-defaultMessage-indentchar.json'; | ||
const sortById = true; | ||
filterPOAndWriteTranslateSync('./test/po/mcs-public.*.po', { | ||
messagesPattern, | ||
output, | ||
sortById, | ||
}); | ||
expect(JSON.parse(fs.readFileSync(output, 'utf8'))).toMatchSnapshot(); | ||
}); |
@@ -1,18 +0,1 @@ | ||
{ | ||
"zh-CN": { | ||
"App.errorMessage": "", | ||
"App.errorButton": "", | ||
"NotFound.errorButton": "", | ||
"App.Creator 1": "建立者(簡中)", | ||
"App.Creator 2": "建立者(簡中)", | ||
"NotFound.Creator": "建立者(簡中)" | ||
}, | ||
"zh-TW": { | ||
"App.errorMessage": "", | ||
"App.errorButton": "", | ||
"NotFound.errorButton": "", | ||
"App.Creator 1": "建立者", | ||
"App.Creator 2": "建立者", | ||
"NotFound.Creator": "建立者" | ||
} | ||
} | ||
{"zh-CN":{"App.Creator 1":"建立者(簡中)","App.Creator 2":"建立者(簡中)","App.errorButton":"","App.errorMessage":"","NotFound.Creator":"建立者(簡中)","NotFound.errorButton":""},"zh-TW":{"App.Creator 1":"建立者","App.Creator 2":"建立者","App.errorButton":"","App.errorMessage":"","NotFound.Creator":"建立者","NotFound.errorButton":""}} |
Sorry, the diff of this file is not supported yet
88166
1167
200