react-i18n-mini-parser
Advanced tools
Comparing version
@@ -46,7 +46,4 @@ "use strict"; | ||
properties.forEach(prop => { | ||
if (typescript_1.default.isPropertyAssignment(prop)) { | ||
if (typescript_1.default.isObjectLiteralExpression(prop.initializer)) { | ||
extractMessageFromProps(prop.initializer.properties, options); | ||
} | ||
} | ||
if (typescript_1.default.isPropertyAssignment(prop) && typescript_1.default.isObjectLiteralExpression(prop.initializer)) | ||
extractMessageFromProps(prop.initializer.properties, options); | ||
}); | ||
@@ -53,0 +50,0 @@ } |
{ | ||
"name": "react-i18n-mini-parser", | ||
"version": "0.2.0", | ||
"description": "NodeJS module for extracting i18n (react-i18n-mini) messages", | ||
"version": "0.3.1", | ||
"description": "NodeJS module for extracting default i18n messages from a project files where using react-i18n-mini.", | ||
"main": "lib/index.js", | ||
@@ -25,3 +25,14 @@ "sideEffects": false, | ||
], | ||
"keywords": [], | ||
"keywords": [ | ||
"intl", | ||
"i18n", | ||
"internationalization", | ||
"locale", | ||
"localization", | ||
"globalization", | ||
"format", | ||
"formatting", | ||
"translate", | ||
"translation" | ||
], | ||
"devDependencies": { | ||
@@ -28,0 +39,0 @@ "@types/jest": "26.0.23", |
# react-i18n-mini-parser | ||
NodeJS module for extracting default i18n messages from a project files where | ||
using [react-i18n-mini](https://www.npmjs.com/package/react-i18n-mini). | ||
### Example of usage | ||
```shell | ||
npm i -D react-i18n-mini-parser | ||
``` | ||
```javascript | ||
import fs from 'fs'; | ||
import glob from 'glob'; | ||
import { extract } from 'react-i18n-mini-parser'; | ||
glob("**/*.+(js|ts|tsx)", function(error, files) { | ||
const messages = extract(files.map(file => fs.readFileSync(file, 'utf8'))); | ||
fs.writeFileSync('./locales/en.json', JSON.stringify(messages, null, ' '), 'utf8'); | ||
}); | ||
``` | ||
Note: `glog` is using as an example. You can use any tool or write your own to find all files that need to be parsed. |
Sorry, the diff of this file is not supported yet
14484
5.99%24
1100%163
-1.81%