generated from Gallardo7761/miarma-template-full
Add: backend dir and moved frontend to frontend dir
This commit is contained in:
33
frontend/src/components/LanguageButton.jsx
Normal file
33
frontend/src/components/LanguageButton.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import NavItem from '@/components/NavBar/NavItem';
|
||||
|
||||
const LanguageButton = ({ as = "button", index = null }) => {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const toggleLanguage = () => {
|
||||
console.log(i18n.language);
|
||||
const nextLang = i18n.language === "es" ? "en" : "es";
|
||||
i18n.changeLanguage(nextLang);
|
||||
};
|
||||
|
||||
if (as === "navitem") {
|
||||
return (
|
||||
<NavItem
|
||||
item={{
|
||||
label: i18n.language === "es" ? "🇪🇸" : "🇺🇸",
|
||||
href: "#"
|
||||
}}
|
||||
index={index}
|
||||
onClick={toggleLanguage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<button onClick={toggleLanguage} className="btn-imperial">
|
||||
{i18n.language === "es" ? "🇪🇸" : "🇺🇸"}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageButton;
|
||||
Reference in New Issue
Block a user