SanichKotikov / react-i18n-mini-parser

NodeJS module for extracting default i18n messages from a project files where using react-i18n-mini.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-i18n-mini-parser

NodeJS module for extracting i18n messages.

Can be used with:

Example of usage

npm i -D react-i18n-mini-parser
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: glob is using as an example. You can use any tool or write your own to find all files that need to be parsed.

About

NodeJS module for extracting default i18n messages from a project files where using react-i18n-mini.

License:MIT License


Languages

Language:TypeScript 99.4%Language:JavaScript 0.6%