Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
babel-plugin-mickey-i18n
Advanced tools
Extract i18n message files and replace text with i18n-formatter.
Extract i18n message files and replace text with i18n-formatter.
React Intl is awesome. But, defineMessages is hard-coding, also Global ID management is difficult and confusing.
This plugin releases you from tedious codings, helps you building react components without any perceptions of i18n.
Take a look at the following component:
import React from 'react';
export default class HelloI18n extends React.Component {
constructor(props) {
super(props);
this.hello = '你好';
this.template = `你好,${this.state.name}`
}
state = {
hello: '你好',
name: '小明',
}
render() {
const { hello, name } = this.state;
return (
<div title="小明,你好">
<p>{name},{hello}</p>
<p>小明,你好</p>
</div>
);
}
}
Compiled with this plugin, result that all the Chinese characters in this component ware replaced with _i18n
mathod which exported from mickey-i18n(the client for localized messages):
import { i18n as _i18n } from "mickey-i18n";
import React from 'react';
export default class HelloI18n extends React.Component {
constructor(props) {
super(props);
this.hello = _i18n("652829", "你好");
this.template = _i18n("-743864039", "你好,{0}", [this.state.name])
}
state = {
hello: _i18n("652829", "你好"),
name: _i18n("756703", "小明"),
}
render() {
const { hello, name } = this.state;
return (
<div title={_i18n("1131501034", "小明,你好")}>
<p>{name},{hello}</p>
<p>{_i18n("1131501034", "小明,你好", [], true)}</p>
</div>
);
}
}
We also get a message file like this, the id is the text's hashcode:
[
{
"id": 652829,
"text": "你好",
},
{
"id": -743864039,
"text": "你好,{0}",
},
{
"id": 756703,
"text": "小明",
},
{
"id": 1131501034,
"text": "小明,你好",
},
]
Then we can use atool-l10n to automatically generate localization resource.
npm install babel-plugin-mickey-i18n --save-dev
npm install mickey-i18n react react-dom react-intl --save
Add the following section in your .babelrc:
{
"plugins": ["mickey-i18n", { "dest": "./i18n_messages" }]
}
dest
The target directory of message file. Default: ./i18n_messages
filename
The target file name of message file. Default: i18n.json
debug
If true
we will get message files of each component. Default: false
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.
FAQs
Extract i18n message files and replace text with i18n-formatter.
The npm package babel-plugin-mickey-i18n receives a total of 2,302 weekly downloads. As such, babel-plugin-mickey-i18n popularity was classified as popular.
We found that babel-plugin-mickey-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.