Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
babel-plugin-lingui-extract-messages
Advanced tools
This plugin collects message ids from
Trans
components
babel-plugin-lingui-transform-react
converts children of Trans
component to ICU message format which serves as a message ID. The message IDs are used in message catalogue and translations are assigned to it.
For example following message:
<Trans>
<Plural
value={count}
one="There's one item matching filter"
other="There're # items matching filter"
/>
(see <a href="?all">all</a>).
</Trans>
is converted to ICU message format:
<Trans
id="{count, plural, one {There's one item matching filter} other {There're # items matching filter}} (see <0>all</0>)"
params={{ count: count }}
components={[
<a href="?all" />
]}
/>
And following message ID is extracted:
{
"{count, plural, one {There's one item matching filter} other {There're # items matching filter}} (see <0>all</0>)": {
"origin": [
["App.js", 3]
]
}
}
Finall, all files under {localeDir}/_build
needs to be merged into final message catalog. This message catalog can be translated into target languages and loaded back to app.
Each item in generated file is in format [messageId: string]: metadata
, where metadata contains following information:
origin
- Array of filenames and line numbers from where the message is extracteddefaults
- Default message if custom messageId is used (<Trans id="msg">Custom message ID</Trans>
becomes <Trans id="msg" defaults="Custom message ID" />
)npm install --save-dev babel-plugin-lingui-extract-messages
# or
yarn add --dev babel-plugin-lingui-extract-messages
.babelrc
(Recommended).babelrc
{
"plugins": ["lingui-extract-messages"]
}
babel --plugins lingui-extract-messages script.js
require("babel-core").transform("code", {
plugins: ["lingui-extract-messages"]
})
localeDir
string
, defaults to locale
.
Directory with locales. Files are written to _build
subdirectory, one json
file per each processed file.
{
"plugins": [
["lingui-extract-messages", {
"localeDir": "./locale"
}]
]
}
FAQs
Extract messages for translation
We found that babel-plugin-lingui-extract-messages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.