Skip to main content
Version: 5.x.x

Switching Language

To manage an event like language change, the React SDK provides the useTolgee hook.

Pass the language event to the hook to re-render the component when the event emits.

import { useTolgee } from '@tolgee/react';

export const LangSelector = () => {
const tolgee = useTolgee(['language']);

return (
<select
onChange={(e) => tolgee.changeLanguage(e.target.value)}
value={tolgee.getLanguage()}
>
<option value="en">🇬🇧 English</option>
<option value="cs">🇨🇿 Česky</option>
</select>
);
};

Learn more about language change, detection and storage on the Language documentation page.