Fix I18n and testing (#387)

Get snapshots working with Gatsby Intl plugin.
This commit is contained in:
TomNUSDS 2021-07-20 10:46:13 -07:00 committed by GitHub
commit 609506d98d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 188 additions and 179 deletions

View file

@ -1,6 +1,15 @@
import React, {ReactNode} from 'react';
import {IntlContextProvider} from 'gatsby-plugin-intl';
import {IntlProvider, IntlContextProvider} from 'gatsby-plugin-intl';
import messages from '../intl/en.json'; // this is updated by `formatjs extract`
const intlConfig = {
language: 'en',
languages: ['en', 'es'],
messages,
originalPath: '/',
redirect: true,
routed: true,
};
interface ILocalizedComponentProps {
children: ReactNode
}
@ -8,8 +17,10 @@ interface ILocalizedComponentProps {
export const LocalizedComponent = ({children}: ILocalizedComponentProps) => {
return (
<>
<IntlContextProvider value={{language: 'en', routed: true}}>
{children}
<IntlContextProvider value={intlConfig} >
<IntlProvider locale={'en'}>
{children}
</IntlProvider>
</IntlContextProvider>,
</>
);