Created
August 28, 2019 17:50
-
-
Save AdamRamberg/34a59b2511e3353f6058c3bef0859742 to your computer and use it in GitHub Desktop.
Translate your React app with ease using Facebook's own framework (FBT) - toggleLocale.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { LocaleConsumer } from 'fbt-easy-setup'; | |
import fbt from 'fbt'; | |
const ToggleLocale = () => ( | |
<LocaleConsumer> | |
{({ locale, setLocale }) => ( | |
<button | |
type="button" | |
onClick={() => setLocale(locale === 'sv_SE' ? 'en_US' : 'sv_SE')} | |
> | |
<fbt desc="Toggle locale button"> | |
Toggle Locale | |
</fbt> | |
</button> | |
)} | |
</LocaleConsumer> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment