
Research
/Security News
Chrome and Firefox Extensions Posing as Free VPNs Add Clipboard Stealers via Malicious Updates
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.
react-i18n-autoreplace
Advanced tools
国际化文案批量替换 react-i18n-autoreplace, Automatically scan the project for Chinese text and replace it with i18n format for translation
1、在项目根目录新建js脚本文件
// replace-i18n.js
const { ReplaceI18n } = require('react-i18n-autoreplace');
const config = {
entry: './src/pages/i18n/index.tsx',
baiduConfig:{
appId: "xxxxx",
bdKey: "xxxxx"
},
}
const replaceTask = new ReplaceI18n(config);
replaceTask.init();
// package.json
"replace": "node ./replace-i18n.js"
2、在命令行启动脚本
```js
npm run replace
export interface IAutoReplaceTextI18nConfig {
entry: string; // 入口文件
project?: string; // 项目名 用来生成okr的key
moduleName?: string; // 功能模块名
pageName?: string; // 页面
point?: string; // 页面功能点
manualHandlingSameText?: boolean; // 是否手动替换相同文案为同一key
manualHandlerErrorTrans?: boolean; // 是否手动替换翻译失败文案
fetchTranslate?: TranslateFetchFunc; // 请求翻译的方法,如果得译能提供的话,默认内置百度的。
importI18nConfig?: {
prefixFunctionName?: string; // 't'
suffixPath?: string; // '@/config/i18n'
fullPath?: string; // `import { t } from '@/config/t';`
split?: string;
needRelativePath?: boolean; // 生成的key是否加上相对路径
keyWordLength?: number; // 取翻译前多少个单词为key,默认10个
keyAddSource?: boolean; // key上是否加上中文
};
baiduConfig: {
appId: number;
bdKey: string;
to?: string[]; // https://api.fanyi.baidu.com/doc/21
};
deyi?: {
dominTag?: number; // 相关配置 域标签,涉及导出
pageKey?: string;
};
downloadFileName?: string;
prettierOption?: Record<string, any>;
exclude?: (name: string) => boolean; // 排除文件
baseDict?: any; // 基础字典
formaterBaseDictMap?: (
data: string,
url: string
) => Record<string, any> | void; // 格式化字典
}
IAutoReplaceTextI18nConfig 接口用于配置国际化自动替换文本的相关设置。
| 属性名 | 类型 | 描述 |
|---|---|---|
entry | string | 入口文件的路径。 |
project? | string | 项目名,用于生成 OKR 的 key。如果未提供,则不生成。 |
moduleName? | string | 功能模块名。 |
pageName? | string | 页面名称。 |
point? | string | 页面功能点。 |
manualHandlingSameText? | boolean | 是否手动替换相同文案为同一 key。默认为 false。 |
manualHandlerErrorTrans? | boolean | 是否手动替换翻译失败的文案。默认为 false。 |
fetchTranslate? | TranslateFetchFunc | 请求翻译的方法,如果得译能提供的话,默认内置百度的翻译服务。 |
importI18nConfig? | object | 导入国际化配置的相关设置。 |
baiduConfig? | object | 百度翻译服务的配置。 |
deyi? | object | 得译翻译服务的相关配置。 |
downloadFileName? | string | 下载文件的名称。 |
prettierOption? | Record<string, any> | Prettier 格式化工具的配置选项。 |
exclude? | (name: string) => boolean | 排除文件的函数,返回 true 表示排除该文件。 |
baseDict? | any | 基础字典,用于存储翻译文本。 |
formaterBaseDictMap? | `(data: string, url: string) => Record<string, any> | void` |
importI18nConfig 对象包含以下属性:
prefixFunctionName?: string - 前缀函数名称,默认为 't'。suffixPath?: string - 后缀路径,默认为 '@/config/i18n'。fullPath?: string - 完整的导入路径。split?: string - 分隔符。needRelativePath?: boolean - 是否需要相对路径,默认为 false。keyWordLength?: number - 取翻译前多少个单词为 key,默认为 10。keyAddSource?: boolean - key 是否加上中文,默认为 false。baiduConfig 对象包含以下属性:
appId: number - 百度翻译服务的应用程序 ID。bdKey: string - 百度翻译服务的密钥。to?: string[] - 目标语言数组。deyi 对象包含以下属性:
dominTag?: number - 域标签,涉及导出的相关配置。pageKey?: string - 页面的 key。const i18nConfig: IAutoReplaceTextI18nConfig = {
entry: 'path/to/entry/file',
project: 'MyProject',
// 其他配置...
};
FAQs
国际化文案批量替换 react-i18n-autoreplace, Automatically scan the project for Chinese text and replace it with i18n format for translation
The npm package react-i18n-autoreplace receives a total of 16 weekly downloads. As such, react-i18n-autoreplace popularity was classified as not popular.
We found that react-i18n-autoreplace 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.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.