1.2.1 • Published 3 years ago
@marvelsq/extract-locale v1.2.1
extract-locale
使用 babel 自动收集未翻译的文案 并替换为 formatMessage
源文件
const App = (user) => {
return (
<div>
<div>用户名: {user.name}</div>
<div>地址: {user.adderss}</div>
</div>
);
};执行该命令
extract-locale ./src/**/*.{ts,tsx}编译后的文件
import { useIntl } from "xxx/IntlProvider";
const App = (user) => {
const intl = useIntl();
return (
<div>
<div>
{intl.formatMessage("@LOCALE_TEXT_0")} {user.name}
</div>
<div>
{intl.formatMessage("@LOCALE_TEXT_0")} {user.adderss}
</div>
</div>
);
};对应的文案
{
"@LOCALE_TEXT_0": "用户名:",
"@LOCALE_TEXT_1": "地址:"
}参数
主要参数为 文件匹配符
| 参数 | 缩写 | 描述 |
|---|---|---|
| --locale | -l | 输入已存在的 localemap |
| --prefix | -p | 国际化文案的前缀(@LOCALE_TEXT_) |
| --offset | -o | 起始序号(0) |
| --no-auto | -A | 是否禁止自动替换(false) |
| --no-auto-name | 是否禁止自动命名(false) |
1.2.0
3 years ago
1.1.2-alpha.0
3 years ago
1.1.2-alpha.1
3 years ago
1.2.1
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.0
3 years ago