Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
babel-plugin-extract-format-message
Advanced tools
Generate a message id from the default message pattern
Extract messages from formatMessage calls
$ npm install babel-plugin-extract-format-message
.babelrc
(Recommended).babelrc
{
"plugins": [ "extract-format-message", {
"generateId": "underscored_crc32",
"outFile": "locales/en.json"
} ]
}
$ babel --plugins extract-format-message script.js
require("babel-core").transform("code", {
plugins: [
[ "extract-format-message", {
"generateId": "underscored_crc32",
"outFile": "locales/en-US/messages.yml",
"locale": "en-US"
} ]
]
})
generateId
is either a function string -> string
, or one of "literal"
, "normalized"
, "underscored"
, "underscored_crc32"
. Defaults to "underscored_crc32"
outFile
is a path (relative to cwd) to the output file containing extracted messages. Defaults to stdout.format
is a string specifying the target file format. By default the format is inferred from the file extension of outFile
.locale
is the BCP 47 Language Tag string specifying the language of the default messages. This is only used in the yaml
format, to match the Rails conventions. Defaults to "en"
.The structure of the file matches the conventions of Chrome's i18n tools. This is also the default format used if an unrecognized format is specified.
Note that format-message apis expecting all of the translations requires a higher level object with locale keys. The value for each locale matches this format.
{
"hello_67b127a": {
"message": "Hello!",
"description": "Greeting shown on the home page."
}
}
Aliases: javascript
, commonjs
, node
Uses the same structure as json
, but uses Node.js's module.exports
idiom to export the messages.
module.exports = {
"hello_67b127a": {
"message": "Hello!",
"description": "Greeting shown on the home page."
}
}
Uses the same structure as json
, but uses ES6 module syntax to export the messages.
export default {
"hello_67b127a": {
"message": "Hello!",
"description": "Greeting shown on the home page."
}
}
Aliases: yml
, rails
Follows the Ruby on Rails i18n conventions for internationalization messages. Descriptions are added as a comment above the messages they describe.
Note that unlike the other formats, yaml
requires the locale
to be at the top level.
en:
# Greeting shown on the home page.
hello_67b127a: Hello!
This software is free to use under the MIT license. See the LICENSE-MIT file for license text and copyright information.
FAQs
Generate a message id from the default message pattern
We found that babel-plugin-extract-format-message demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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 a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.