Skip to content

Commit

Permalink
Update LocaleProvider when locale changes
Browse files Browse the repository at this point in the history
  • Loading branch information
p-jackson authored and lsl committed Dec 2, 2020
1 parent b551dba commit f498537
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/components/calypso-i18n-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LocaleProvider, i18nDefaultLocaleSlug } from '@automattic/i18n-utils';

const CalypsoI18nProvider: React.FunctionComponent = ( { children } ) => {
const [ localeData, setLocaleData ] = React.useState( i18n.getLocale() );
const localeSlug = i18n.getLocaleSlug();
const [ localeSlug, setLocaleSlug ] = React.useState( i18n.getLocaleSlug() );

React.useEffect( () => {
const onChange = () => {
Expand All @@ -18,6 +18,7 @@ const CalypsoI18nProvider: React.FunctionComponent = ( { children } ) => {

setWpI18nLocaleData( nextLocaleData );
setLocaleData( nextLocaleData );
setLocaleSlug( i18n.getLocaleSlug() );
};

i18n.on( 'change', onChange );
Expand Down

0 comments on commit f498537

Please sign in to comment.