-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Im trying to create language switch menu. It should display all available languages and the selected one. So far i managed to do the following:
import {reactTranslateChangeLanguage} from 'translate-components'
const LangOptions = () => {
const [currLang, setCurrLang] = useState('he');
return (
<div className="lang-options">
{currLang}
<div className="lang-drop-menu">
<button onClick={() => { reactTranslateChangeLanguage('he'); setCurrLang('he'); }}>
He
</button>
<button onClick={() => { reactTranslateChangeLanguage('en'); setCurrLang('en'); }}>
En
</button>
</div>
</div>
);
};
as you can see - im show selected language from hardcoded state ('he').
Im sure there is way to access "defaultLanguage" property of TranslateProvider , but i didnt figured how to do it from docs.
I will very appreciate your help
Thanks
Metadata
Metadata
Assignees
Labels
No labels