| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import { detectLang } from '../messages/index.js';
- interface LangSwitchProps {
- /** Override target paths. [enTarget, ruTarget]. Default: ['/', '/ru'] */
- targets?: [string, string];
- }
- export function LangSwitch({ targets }: LangSwitchProps) {
- const lang = detectLang();
- const [enTarget, ruTarget] = targets ?? ['/', '/ru'];
- const TO: Record<string, { label: string; href: string }> = {
- en: { label: 'en', href: ruTarget },
- ru: { label: 'ru', href: enTarget },
- };
- const { label, href } = TO[lang];
- return (
- <a
- href={href}
- style={{
- position: 'absolute',
- top: '8px',
- right: '12px',
- fontSize: '0.7rem',
- fontWeight: 'bold',
- color: '#787c7e',
- textDecoration: 'none',
- border: 'none',
- background: 'none',
- cursor: 'pointer',
- fontFamily: 'monospace',
- textTransform: 'uppercase',
- }}
- >
- {label}
- </a>
- );
- }
|