
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
react-intl-universal-extract
Advanced tools
Extract react-intl-universal's default messages in source code to locale files.
For example, suppose you have a file:
render() {
const name = 'Tony';
return (<>
{intl.get('hello1').d('Hello World')}
{intl.get('hello2', {name} ).d(`Hello ${name}`)}
</>);
}
This tool will generate a json file which contains the extracted messages.
{
"hello1": "Hello World",
"hello2": "Hello {name}",
}
Note that if the default message contains variables in ES6 template strings format (Hello ${name}
), it will be transformed to ICU format (Hello {name}
).
npm install --save-dev react-intl-universal-extract
In package.json
, add a script:
"scripts": {
"intl:extract": "npx react-intl-universal-extract --cmd extract --source-path ./src --output-path ./src/locales/en_US.json --verbose",
}
Then run npm run intl:extract
.
Parameters:
cmd
: only "extract" is supported currently.source-path
: The source code directory path such as "./src"output-path
: The extracted json file path such as "./src/locales/en_US.json"const intlTool = require('react-intl-universal-extract');
const result = intlTool.extract({
sourcePath: './test-files',
});
console.log(result);
/** result:
[{
key: 'hello2',
path: 'test-files/App.js',
originalDefaultMessage: 'Hello ${name}',
transformedDefaultMessage: 'Hello {name}'
}]
*/
This software is free to use under the BSD license.
See "develop.md"
FAQs
A react-intl-universal message extractor
The npm package react-intl-universal-extract receives a total of 125 weekly downloads. As such, react-intl-universal-extract popularity was classified as not popular.
We found that react-intl-universal-extract demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.