
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@easy-lang/react
Advanced tools
React 项目的多语言翻译工具,基于 easy-lang,支持响应式国际化体验。
pnpm add @easy-lang/react
# 或
npm install @easy-lang/react
# 或
yarn add @easy-lang/react
需额外安装
react
、zustand
、easy-lang
作为 peerDependency。
// translation.json
{
"错误": {
"zh_CN": "错误",
"zh_HK": "錯誤",
"en": "Error"
},
"保存": {
"zh_CN": "保存",
"zh_HK": "保存",
"en": "Save"
}
}
import translations from "./translation.json";
import { createI18nTool } from "easy-lang";
import { createReactI18nTool } from "@easy-lang/react";
const reactI18nTool = createReactI18nTool<
typeof translations,
"zh_CN" | "zh_HK" | "en"
>(
createI18nTool({
defaultLang: "zh_CN",
langs: ["zh_CN", "zh_HK", "en"],
translations,
})
);
export const useTranslate = reactI18nTool.useTranslate();
function App() {
const { $t, changeLang, currentLang } = useTranslate();
return (
<div>
<button onClick={() => changeLang("en")}>en</button>
<button onClick={() => changeLang("zh_CN")}>中文</button>
<div>当前语言: {currentLang}</div>
<div>{$t("错误")}</div>
</div>
);
}
注意:changeLang 调用后会执行 location.reload() 刷新页面。 如果你的项目只用到了 useTranslate 进行翻译,请设置 autoReload: false,可实现响应式更新。
支持在翻译文本中使用 {变量名}
,如:
{
"欢迎": {
"en": "Welcome, {name}!"
}
}
调用:
useTranslate().$t("欢迎", { name: "Tom" }); // => "Welcome, Tom!"
未翻译的 key 会自动收集到 untranslatedList
,便于后续补全。
本项目使用 vitest 进行单元测试。
pnpm test
pnpm build
MIT
FAQs
React bindings for easy-lang
The npm package @easy-lang/react receives a total of 3 weekly downloads. As such, @easy-lang/react popularity was classified as not popular.
We found that @easy-lang/react 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.