
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@brain-toolkit/ts2locales
Advanced tools
`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译,使国际化过程更加简单和规范。
@brain-toolkit/ts2locales 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译,使国际化过程更加简单和规范。
npm install @brain-toolkit/ts2locales --save-dev
# 或
yarn add @brain-toolkit/ts2locales -D
# 或
pnpm add @brain-toolkit/ts2locales -D
在你的 TypeScript 文件中使用特定格式的 JSDoc 注释来定义国际化内容:
/**
* @description 用户名不能为空
* @localZh 用户名不能为空
* @localEn Username cannot be empty
*/
export const USERNAME_EMPTY = 'error.username.empty';
/**
* @description 密码长度必须大于 6 位
* @localZh 密码长度必须大于 6 位
* @localEn Password must be longer than 6 characters
*/
export const PASSWORD_TOO_SHORT = 'error.password.length';
import { Ts2Locales } from '@brain-toolkit/ts2locales';
const ts2locales = new Ts2Locales(['zh', 'en']);
await ts2locales.generate({
source: './src/constants/errors.ts',
target: './src/locales/{{lng}}/errors.json'
});
// vite.config.ts
import { defineConfig } from 'vite';
import { ts2localesVitePlugin } from '@brain-toolkit/ts2locales/vite';
export default defineConfig({
plugins: [
ts2localesVitePlugin({
locales: ['zh', 'en'],
values: [
{
source: './src/constants/errors.ts',
target: './src/locales/{{lng}}/errors.json'
}
]
})
]
});
locales: string[] - 支持的语言代码数组,例如 ['zh', 'en']source: string - 源文件路径target: string - 目标文件路径,使用 {{lng}} 作为语言代码占位符locales: string[] - 支持的语言代码数组values: Array<{ source: string; target: string }> - 源文件和目标文件的映射配置对于上述示例代码,将会生成如下格式的本地化文件:
// locales/zh/errors.json
{
"error.username.empty": "用户名不能为空",
"error.password.length": "密码长度必须大于 6 位"
}
// locales/en/errors.json
{
"error.username.empty": "Username cannot be empty",
"error.password.length": "Password must be longer than 6 characters"
}
@description 标签@local 前缀,如 @localZh、@localEn 等description 作为默认值FAQs
`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译,使国际化过程更加简单和规范。
We found that @brain-toolkit/ts2locales demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.