
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
一个易用、低侵入的多语言翻译工具,适合中大型前端项目的国际化需求。
pnpm add easy-lang
# 或
npm install easy-lang
# 或
yarn add easy-lang
// translation.json
{
"错误": {
"zh_CN": "错误",
"zh_HK": "錯誤",
"en": "Error"
},
"保存": {
"zh_CN": "保存",
"zh_HK": "保存",
"en": "Save"
}
}
import { createI18nTool } from "easy-lang";
import translations from "./translation.json";
const i18n = createI18nTool<typeof translations, "zh_CN" | "zh_HK" | "en">({
defaultLang: "en",
langs: ["zh_CN", "zh_HK", "en"],
translations,
});
// 获取翻译
i18n.$t("错误"); // => "Error"
// 切换语言
i18n.changeLang("zh_CN");
支持在翻译文本中使用 {变量名}
,如:
{
"欢迎": {
"en": "Welcome, {name}!"
}
}
调用:
i18n.$t("欢迎", { name: "Tom" }); // => "Welcome, Tom!"
未翻译的 key 会自动收集到 untranslatedList
,便于后续补全。
本项目使用 vitest 进行单元测试。
pnpm test
pnpm build
MIT
FAQs
An easy-to-use, low-intrusion translation tool
We found that easy-lang 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.