Spaces:
Running
Running
Download frontend/src/app/components/LanguageSwitcher.js from davebulaval/cole: direct link, hf CLI and curl.
- Browser
- Download file 803 Bytes
-
https://huggingface.co/spaces/davebulaval/cole/resolve/main/frontend/src/app/components/LanguageSwitcher.js
- Command line
-
hf download hf://spaces/davebulaval/cole/frontend/src/app/components/LanguageSwitcher.js
-
curl -L -o LanguageSwitcher.js https://huggingface.co/spaces/davebulaval/cole/resolve/main/frontend/src/app/components/LanguageSwitcher.js
803 Bytes
| 'use client'; | |
| import {useTranslation} from 'react-i18next'; | |
| export function LanguageSwitcher() { | |
| const {i18n} = useTranslation(); | |
| const currentLang = i18n.language?.startsWith('fr') ? 'fr' : 'en'; | |
| const btnStyle = (lng) => | |
| lng === currentLang | |
| ? 'px-2 py-1 rounded-lg border-2 border-blue-600 bg-blue-600 text-white font-semibold' | |
| : 'px-2 py-1 rounded-lg border border-gray-300 text-gray-500 hover:border-gray-400'; | |
| return ( | |
| <div className="flex space-x-1"> | |
| <button onClick={() => i18n.changeLanguage('en')} className={btnStyle('en')}> | |
| EN | |
| </button> | |
| <button onClick={() => i18n.changeLanguage('fr')} className={btnStyle('fr')}> | |
| FR | |
| </button> | |
| </div> | |
| ); | |
| } | |