Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@lingui/babel-plugin-extract-messages
Advanced tools
@lingui/babel-plugin-extract-messages is a Babel plugin designed to extract messages from your code for internationalization (i18n) purposes. It works in conjunction with the LinguiJS framework to help developers manage and translate text in their applications.
Extracting Messages
This feature allows you to extract messages from your codebase into a specified directory. The configuration specifies the directory where the extracted messages will be stored and whether to extract messages from `formatMessage` calls.
```json
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"@lingui/babel-plugin-extract-messages",
{
"localeDir": "./locales/",
"extractFromFormatMessageCall": true
}
]
]
}
```
Custom Message Extraction
This feature allows you to define custom formatters for message extraction. The configuration includes a custom formatter with a specific name and pattern, enabling more flexible message extraction.
```json
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"@lingui/babel-plugin-extract-messages",
{
"localeDir": "./locales/",
"extractFromFormatMessageCall": true,
"customFormatters": [
{
"name": "customFormatter",
"pattern": "customPattern"
}
]
}
]
]
}
```
babel-plugin-react-intl is a Babel plugin for extracting messages from React components that use the react-intl library. It is similar to @lingui/babel-plugin-extract-messages but is specifically designed for use with react-intl, making it a good choice for projects already using that library.
i18next-extract-gettext is a tool for extracting translation keys from JavaScript and TypeScript codebases that use the i18next library. It provides similar functionality to @lingui/babel-plugin-extract-messages but is tailored for use with i18next, offering a different approach to internationalization.
Babel plugin which extracts messages for translation from source files
@lingui/babel-plugin-extract-messages
is part of js-lingui. See the documentation for all information, tutorials and examples.
yarn add --dev @lingui/babel-plugin-extract-messages
# npm install --save-dev @lingui/babel-plugin-extract-messages
.babelrc
(Recommended).babelrc
{
"plugins": ["@lingui/babel-plugin-extract-messages"]
}
babel --plugins @lingui/babel-plugin-extract-messages script.js
require("@babel/core").transform("code", {
plugins: ["@lingui/babel-plugin-extract-messages"]
})
FAQs
Babel plugin for collecting messages from source code for internationalization
The npm package @lingui/babel-plugin-extract-messages receives a total of 101,422 weekly downloads. As such, @lingui/babel-plugin-extract-messages popularity was classified as popular.
We found that @lingui/babel-plugin-extract-messages demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.