Add language translation system and weather widget with admin controls
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getLanguage, setLanguage } from '@/lib/i18n';
|
||||
|
||||
export default function LanguageSwitcher() {
|
||||
const [currentLang, setCurrentLang] = useState<'en' | 'es'>('en');
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentLang(getLanguage());
|
||||
}, []);
|
||||
|
||||
const toggleLanguage = () => {
|
||||
const newLang = currentLang === 'en' ? 'es' : 'en';
|
||||
setLanguage(newLang);
|
||||
setCurrentLang(newLang);
|
||||
// Reload the page to apply the language change
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={toggleLanguage}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: '1rem',
|
||||
left: '1rem',
|
||||
zIndex: 1000,
|
||||
background: 'rgba(255, 255, 255, 0.9)',
|
||||
border: '1px solid #ddd',
|
||||
borderRadius: '4px',
|
||||
padding: '0.5rem 1rem',
|
||||
cursor: 'pointer',
|
||||
fontSize: '0.9rem',
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{currentLang === 'en' ? 'ES' : 'EN'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user