Updates intl file with latest copy (#795)

* Extract 404 page copy to intl

* Move all copy to data copy folder and add tests

- Add test:intl-extraction script
- Fix certain defaultMessages not appearing
- update snapshot
This commit is contained in:
Vim 2021-10-14 13:49:16 -07:00 committed by GitHub
commit d1511287b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 199 additions and 140 deletions

View file

@ -1,11 +1,11 @@
import * as React from 'react';
import {defineMessages} from 'react-intl';
import {Link} from 'gatsby-plugin-intl';
import {useIntl} from 'gatsby-plugin-intl';
import {Grid} from '@trussworks/react-uswds';
import J40MainGridContainer from '../components/J40MainGridContainer';
import Layout from '../components/layout';
import * as PAGE_NOT_FOUND_COPY from '../data/copy/404';
const codeStyles = {
color: '#8A6534',
@ -22,62 +22,30 @@ interface I404PageProps {
// markup
const NotFoundPage =({location}: I404PageProps) => {
const intl = useIntl();
const messages = defineMessages({
pageNotFoundTitle: {
id: 'pageNotFound.title.text',
defaultMessage: 'Page not found',
description: 'page not found title text',
},
pageNotFoundHeading: {
id: 'pageNotFound.heading.text',
defaultMessage: 'Page not found',
description: 'page not found heading text',
},
pageNotFoundApology: {
id: 'pageNotFound.apology.text',
defaultMessage: 'Sorry',
description: 'page not found apology text',
},
pageNotFoundApologyDescription: {
id: 'pageNotFound.apology.description.text',
defaultMessage: 'we couldnt find what you were looking for.',
description: 'page not found apology description text',
},
pageNotFoundGuidance: {
id: 'pageNotFound.Guidance.text',
defaultMessage: 'Try creating a page in',
description: 'page not found guidance text',
},
pageNotFoundLinkToGoHome: {
id: 'pageNotFound.link.to.go.home.text',
defaultMessage: 'Go home',
description: 'page not found link to go home text',
},
});
return (
<Layout location={location} title={intl.formatMessage(messages.pageNotFoundTitle)}>
<Layout location={location} title={intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.TITLE)}>
<J40MainGridContainer>
<Grid row>
<h1>{intl.formatMessage(messages.pageNotFoundHeading)}</h1>
<h1>{intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.HEADING)}</h1>
</Grid>
<Grid row>
<p>
{intl.formatMessage(messages.pageNotFoundApology)}
{intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.APOLOGY)}
{' '}
<span role="img" aria-label="Pensive emoji">
😔
</span>{' '}
{intl.formatMessage(messages.pageNotFoundApologyDescription)}
{intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.APOLOGY_INFO)}
</p>
</Grid>
<Grid row>
{process.env.NODE_ENV === 'development' ? (
<p>
{intl.formatMessage(messages.pageNotFoundGuidance)}
{intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.GUIDANCE)}
<code style={codeStyles}>src/pages/</code>.
</p>
) : null}
@ -85,7 +53,7 @@ const NotFoundPage =({location}: I404PageProps) => {
<Grid>
<p>
<Link to="/">{intl.formatMessage(messages.pageNotFoundLinkToGoHome)}</Link>.
<Link to="/">{intl.formatMessage(PAGE_NOT_FOUND_COPY.PAGE.LINK_HOME)}</Link>.
</p>
</Grid>