Series: vibe coding
javascript
30 lines
· Updated 2026-04-26
LanguageSwitcher.jsx
vibe_coding/src/components/LanguageSwitcher.jsx
import { useTranslation } from 'react-i18next';
const LANGS = [
{ code: 'es', label: 'ES' },
{ code: 'en', label: 'EN' },
{ code: 'zh', label: '中' }
];
export default function LanguageSwitcher() {
const { i18n } = useTranslation();
const current = (i18n.resolvedLanguage || i18n.language || 'es').slice(0, 2);
return (
<div className="lang" aria-label="Language switcher">
{LANGS.map((l, idx) => (
<span key={l.code} style={{ display: 'inline-flex', alignItems: 'center' }}>
<button
type="button"
className={current === l.code ? 'active' : ''}
onClick={() => i18n.changeLanguage(l.code)}
aria-label={`Switch to ${l.label}`}
>
{l.label}
</button>
{idx < LANGS.length - 1 && <span className="lang__sep">·</span>}
</span>
))}
</div>
);
}
Related articles
vibe coding
javascript
Updated 2026-04-26
App.jsx
App.jsx — javascript source code from the vibe coding learning materials (vibe_coding/src/App.jsx).
Read article →
vibe coding
javascript
Updated 2026-04-26
Footer.jsx
Footer.jsx — javascript source code from the vibe coding learning materials (vibe_coding/src/components/Footer.jsx).
Read article →
vibe coding
javascript
Updated 2026-04-26
Navbar.jsx
Navbar.jsx — javascript source code from the vibe coding learning materials (vibe_coding/src/components/Navbar.jsx).
Read article →
vibe coding
javascript
Updated 2026-04-26
ProjectCard.jsx
ProjectCard.jsx — javascript source code from the vibe coding learning materials (vibe_coding/src/components/ProjectCard.jsx).
Read article →
vibe coding
javascript
Updated 2026-04-26
ScrollToTop.jsx
ScrollToTop.jsx — javascript source code from the vibe coding learning materials (vibe_coding/src/components/ScrollToTop.jsx).
Read article →
vibe coding
javascript
Updated 2026-04-26
projects.js
projects.js — javascript source code from the vibe coding learning materials (vibe_coding/src/data/projects.js).
Read article →