
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.
@ui18n/selector-react
Advanced tools
🎨 Beautiful, accessible language selector component for React with auto-discovery, custom styling, and zero dependencies
极简、可访问的语言选择下拉(React)。默认仅中/英,支持自动发现 /.ui18n/languages.json 扩展语言。无统计、无后端依赖,开放而轻量。
特性
安装
快速上手 import { UI18nLanguageDropdown } from "@ui18n/selector-react";
function Example() { const [lang, setLang] = React.useState("en"); return ( <UI18nLanguageDropdown value={lang} onChange={setLang} // 默认仅 ["en","zh-CN"],可传入扩展列表 languages={["en","zh-CN","ja-JP"]} // 自动发现(默认 true);可关闭或自定义路径 autoDiscover discoverPath="/.ui18n/languages.json" placeholder="搜索语言…" className="w-full max-w-sm" /> ); }
自动发现协议
API
组件 UI18nLanguageDropdown
Hooks/工具(按需引入)
预览能力(可选)
function Demo() { async function preview({ text, to, from }: { text: string; to: string; from?: string }) { const res = await fetch("/api/translate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text, to, from, model: "glm-4.5-flash" }), }); if (!res.ok) throw new Error(String(res.status)); const data = await res.json(); if (data?.ok) return String(data.data ?? ""); throw new Error(String(data?.error ?? "preview_failed")); }
return ( <UI18nLanguageDropdown value={"en"} onChange={() => {}} previewText="Hello world" onPreviewRequest={preview} /> ); }
样式
可访问性
建议集成方式
开源协议
最小集成片段
Vite(React + Vite)
// main.tsx
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
// App.tsx
import * as React from "react";
import { UI18nLanguageDropdown } from "@ui18n/selector-react";
export default function App() {
const [lang, setLang] = React.useState("en");
return (
<div style={{ padding: 16 }}>
<UI18nLanguageDropdown
value={lang}
onChange={setLang}
languages={["en", "zh-CN"]}
autoDiscover
discoverPath="/.ui18n/languages.json"
placeholder="搜索语言…"
/>
</div>
);
}
Next.js(App Router)
// app/page.tsx (服务端)
// 推荐在 Client 组件中使用语言下拉
export default function Page() {
return <ClientHome />;
}
// app/client-home.tsx
"use client";
import * as React from "react";
import { UI18nLanguageDropdown } from "@ui18n/selector-react";
export default function ClientHome() {
const [lang, setLang] = React.useState("en");
return (
<UI18nLanguageDropdown
value={lang}
onChange={setLang}
autoDiscover
placeholder="搜索语言…"
/>
);
}
Create React App
// App.tsx
import * as React from "react";
import { UI18nLanguageDropdown } from "@ui18n/selector-react";
function App() {
const [lang, setLang] = React.useState("en");
return (
<UI18nLanguageDropdown
value={lang}
onChange={setLang}
languages={["en", "zh-CN", "ja-JP"]}
/>
);
}
export default App;
A11y 键盘导航清单
FAQs
🎨 Beautiful, accessible language selector component for React with auto-discovery, custom styling, and zero dependencies
We found that @ui18n/selector-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.

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.