Implementing translations

This commit is contained in:
Jeff Avallone 2019-01-06 13:03:07 -05:00
parent e1c4cb9068
commit 618b21bb93
19 changed files with 1296 additions and 705 deletions

View File

@ -11,6 +11,7 @@ ShallowWrapper {
},
}
}
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
@ -30,14 +31,17 @@ ShallowWrapper {
className="list"
>
<li>
<WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>
</li>
<li>
<WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
@ -45,10 +49,11 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>
</li>
</ul>,
<div
@ -68,14 +73,17 @@ ShallowWrapper {
"props": Object {
"children": Array [
<li>
<WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>
</li>,
<li>
<WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
@ -83,10 +91,11 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>
</li>,
],
"className": "list",
@ -97,6 +106,21 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"Created by ",
@ -123,12 +147,34 @@ ShallowWrapper {
"type": "a",
},
],
"type": [Function],
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"Generated images licensed: ",
@ -138,7 +184,7 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>,
@ -153,7 +199,7 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"children": <img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>,
"href": "http://creativecommons.org/licenses/by/3.0/",
@ -166,7 +212,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "host",
"props": Object {
"alt": "Creative Commons CC-BY-3.0 License",
"alt": "TRANSLATE(Creative Commons CC-BY-3.0 License)",
"src": "https://licensebuttons.net/l/by/3.0/80x15.png",
},
"ref": null,
@ -176,6 +222,8 @@ ShallowWrapper {
"type": "a",
},
],
"type": [Function],
},
"type": "li",
},
],
@ -207,14 +255,17 @@ ShallowWrapper {
className="list"
>
<li>
<WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>
</li>
<li>
<WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
@ -222,10 +273,11 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>
</li>
</ul>,
<div
@ -245,14 +297,17 @@ ShallowWrapper {
"props": Object {
"children": Array [
<li>
<WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>
</li>,
<li>
<WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
@ -260,10 +315,11 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>
</li>,
],
"className": "list",
@ -274,6 +330,21 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"Created by ",
@ -300,12 +371,34 @@ ShallowWrapper {
"type": "a",
},
],
"type": [Function],
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"Generated images licensed: ",
@ -315,7 +408,7 @@ ShallowWrapper {
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>,
@ -330,7 +423,7 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"children": <img
alt="Creative Commons CC-BY-3.0 License"
alt="TRANSLATE(Creative Commons CC-BY-3.0 License)"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>,
"href": "http://creativecommons.org/licenses/by/3.0/",
@ -343,7 +436,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "host",
"props": Object {
"alt": "Creative Commons CC-BY-3.0 License",
"alt": "TRANSLATE(Creative Commons CC-BY-3.0 License)",
"src": "https://licensebuttons.net/l/by/3.0/80x15.png",
},
"ref": null,
@ -353,6 +446,8 @@ ShallowWrapper {
"type": "a",
},
],
"type": [Function],
},
"type": "li",
},
],

View File

@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { StaticQuery, graphql } from 'gatsby';
import { withNamespaces, Trans } from 'react-i18next';
import style from './style.module.css';
@ -14,20 +15,21 @@ const query = graphql`
}
`;
export const FooterImpl = ({ site: { siteMetadata } }) => (
export const FooterImpl = ({ t, site: { siteMetadata } }) => (
<footer className={ style.footer }>
<ul className={ style.list }>
<li>
Created by <a href="mailto:jeff.avallone@gmail.com">Jeff Avallone</a>
<Trans>Created by <a
href="mailto:jeff.avallone@gmail.com">Jeff Avallone</a></Trans>
</li>
<li>
Generated images licensed: <a
<Trans>Generated images licensed: <a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank">
<img src="https://licensebuttons.net/l/by/3.0/80x15.png"
alt="Creative Commons CC-BY-3.0 License" />
</a>
alt={ t('Creative Commons CC-BY-3.0 License') } />
</a></Trans>
</li>
</ul>
<div className={ style.buildId }>
@ -37,6 +39,7 @@ export const FooterImpl = ({ site: { siteMetadata } }) => (
);
FooterImpl.propTypes = {
t: PropTypes.func.isRequired,
site: PropTypes.shape({
siteMetadata: PropTypes.shape({
buildId: PropTypes.string.isRequired
@ -44,8 +47,9 @@ FooterImpl.propTypes = {
}).isRequired
};
const TranslatedFooter = withNamespaces()(FooterImpl);
const Footer = () => <StaticQuery query={ query } render={ data => (
<FooterImpl { ...data } />
<TranslatedFooter { ...data } />
) } />;
export default Footer;

View File

@ -1,6 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { mockT } from 'i18n';
import Footer, { FooterImpl } from 'components/Footer';
describe('Footer', () => {
@ -13,7 +14,7 @@ describe('Footer', () => {
test('rendering implementation', () => {
const component = shallow(
<FooterImpl site={{ siteMetadata: { buildId: 'abc-123' } }} />
<FooterImpl site={{ siteMetadata: { buildId: 'abc-123' } }} t={ mockT } />
);
expect(component).toMatchSnapshot();
});

View File

@ -46,14 +46,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>
<li>
@ -108,14 +112,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>,
<li>
@ -140,7 +148,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>,
},
"ref": null,
@ -154,7 +164,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>,
"Source on GitLab",
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>,
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
@ -174,7 +186,17 @@ ShallowWrapper {
"rendered": null,
"type": [Function],
},
"Source on GitLab",
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Source on GitLab",
},
"ref": null,
"rendered": "Source on GitLab",
"type": [Function],
},
],
"type": "a",
},
@ -188,7 +210,9 @@ ShallowWrapper {
"children": <mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>,
},
"ref": null,
@ -197,11 +221,23 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"children": <WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>,
"to": "/privacy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Privacy Policy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [Function],
},
"type": [MockFunction],
},
"type": "li",
@ -258,14 +294,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>
<li>
@ -320,14 +360,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>,
<li>
@ -352,7 +396,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>,
},
"ref": null,
@ -366,7 +412,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>,
"Source on GitLab",
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>,
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
@ -386,7 +434,17 @@ ShallowWrapper {
"rendered": null,
"type": [Function],
},
"Source on GitLab",
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Source on GitLab",
},
"ref": null,
"rendered": "Source on GitLab",
"type": [Function],
},
],
"type": "a",
},
@ -400,7 +458,9 @@ ShallowWrapper {
"children": <mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>,
},
"ref": null,
@ -409,11 +469,23 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"children": <WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>,
"to": "/privacy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Privacy Policy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [Function],
},
"type": [MockFunction],
},
"type": "li",
@ -510,14 +582,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>
<li>
@ -572,14 +648,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>,
<li>
@ -604,7 +684,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>,
},
"ref": null,
@ -618,7 +700,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>,
"Source on GitLab",
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>,
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
@ -638,7 +722,17 @@ ShallowWrapper {
"rendered": null,
"type": [Function],
},
"Source on GitLab",
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Source on GitLab",
},
"ref": null,
"rendered": "Source on GitLab",
"type": [Function],
},
],
"type": "a",
},
@ -652,7 +746,9 @@ ShallowWrapper {
"children": <mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>,
},
"ref": null,
@ -661,11 +757,23 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"children": <WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>,
"to": "/privacy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Privacy Policy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [Function],
},
"type": [MockFunction],
},
"type": "li",
@ -722,14 +830,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>
<li>
@ -784,14 +896,18 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>
</li>,
<li>
@ -816,7 +932,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>
</a>,
},
"ref": null,
@ -830,7 +948,9 @@ ShallowWrapper {
color="currentColor"
size="24"
/>,
"Source on GitLab",
<WithMergedOptions(TransComponent)>
Source on GitLab
</WithMergedOptions(TransComponent)>,
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
@ -850,7 +970,17 @@ ShallowWrapper {
"rendered": null,
"type": [Function],
},
"Source on GitLab",
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Source on GitLab",
},
"ref": null,
"rendered": "Source on GitLab",
"type": [Function],
},
],
"type": "a",
},
@ -864,7 +994,9 @@ ShallowWrapper {
"children": <mockConstructor
to="/privacy"
>
<WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>
</mockConstructor>,
},
"ref": null,
@ -873,11 +1005,23 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"children": <WithMergedOptions(TransComponent)>
Privacy Policy
</WithMergedOptions(TransComponent)>,
"to": "/privacy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Privacy Policy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [Function],
},
"type": [MockFunction],
},
"type": "li",

View File

@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link, StaticQuery, graphql } from 'gatsby';
import { withNamespaces, Trans } from 'react-i18next';
import GitlabIcon from 'react-feather/dist/icons/gitlab';
@ -32,11 +33,13 @@ export const HeaderImpl = ({ site: { siteMetadata } }) => (
rel="external noopener noreferrer"
target="_blank">
<GitlabIcon />
Source on GitLab
<Trans>Source on GitLab</Trans>
</a>
</li>
<li>
<Link to="/privacy">Privacy Policy</Link>
<Link to="/privacy">
<Trans>Privacy Policy</Trans>
</Link>
</li>
<li>
<LocaleSwitcher />
@ -56,8 +59,9 @@ HeaderImpl.propTypes = {
}).isRequired
};
const TranslatedHeader = withNamespaces()(HeaderImpl);
const Header = () => <StaticQuery query={ query } render={ data => (
<HeaderImpl { ...data } />
<TranslatedHeader { ...data } />
) } />;
export default Header;

View File

@ -3,7 +3,9 @@
exports[`SentryError rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <SentryError />,
Symbol(enzyme.__unrendered__): <SentryErrorImpl
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
@ -18,6 +20,7 @@ ShallowWrapper {
"nodeType": "function",
"props": Object {
"children": <p>
<WithMergedOptions(TransComponent)>
This error has been logged. You may also
<a
href="#error-report"
@ -26,8 +29,9 @@ ShallowWrapper {
fill out a report
</a>
.
</WithMergedOptions(TransComponent)>
</p>,
"heading": "An error has occurred",
"heading": "TRANSLATE(An error has occurred)",
"type": "error",
},
"ref": null,
@ -35,6 +39,23 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
This error has been logged. You may also
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>
.
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"This error has been logged. You may also ",
@ -65,6 +86,8 @@ ShallowWrapper {
},
".",
],
"type": [Function],
},
"type": "p",
},
"type": [Function],
@ -76,6 +99,7 @@ ShallowWrapper {
"nodeType": "function",
"props": Object {
"children": <p>
<WithMergedOptions(TransComponent)>
This error has been logged. You may also
<a
href="#error-report"
@ -84,8 +108,9 @@ ShallowWrapper {
fill out a report
</a>
.
</WithMergedOptions(TransComponent)>
</p>,
"heading": "An error has occurred",
"heading": "TRANSLATE(An error has occurred)",
"type": "error",
},
"ref": null,
@ -93,6 +118,23 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
This error has been logged. You may also
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>
.
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
"This error has been logged. You may also ",
@ -123,6 +165,8 @@ ShallowWrapper {
},
".",
],
"type": [Function],
},
"type": "p",
},
"type": [Function],

View File

@ -1,9 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as Sentry from '@sentry/browser';
import { withNamespaces, Trans } from 'react-i18next';
import Message from 'components/Message';
class SentryError extends React.Component {
export class SentryErrorImpl extends React.Component {
reportError = event => {
event.preventDefault();
@ -13,11 +15,19 @@ class SentryError extends React.Component {
}
render() {
return <Message type="error" heading="An error has occurred">
<p>This error has been logged. You may also <a href="#error-report"
onClick={ this.reportError }>fill out a report</a>.</p>
const { t } = this.props;
return <Message type="error" heading={ t('An error has occurred') }>
<p>
<Trans>This error has been logged. You may also <a href="#error-report"
onClick={ this.reportError }>fill out a report</a>.</Trans>
</p>
</Message>;
}
}
export default SentryError;
SentryErrorImpl.propTypes = {
t: PropTypes.func.isRequired
};
export default withNamespaces()(SentryErrorImpl);

View File

@ -4,12 +4,13 @@ import React from 'react';
import { shallow } from 'enzyme';
import * as Sentry from '@sentry/browser';
import SentryError from 'components/SentryError';
import { mockT } from 'i18n';
import { SentryErrorImpl } from 'components/SentryError';
describe('SentryError', () => {
test('rendering', () => {
const component = shallow(
<SentryError />
<SentryErrorImpl t={ mockT }/>
);
expect(component).toMatchSnapshot();
});
@ -18,7 +19,7 @@ describe('SentryError', () => {
test('fill out a report when an event has been logged', () => {
Sentry.lastEventId.mockReturnValue(1);
const component = shallow(
<SentryError />
<SentryErrorImpl t={ mockT } />
);
const eventObj = { preventDefault: jest.fn() };
component.find('a').simulate('click', eventObj);
@ -30,7 +31,7 @@ describe('SentryError', () => {
test('fill out a report when an event has not been logged', () => {
Sentry.lastEventId.mockReturnValue(false);
const component = shallow(
<SentryError />
<SentryErrorImpl t={ mockT } />
);
const eventObj = { preventDefault: jest.fn() };
component.find('a').simulate('click', eventObj);

View File

@ -1,2 +1,45 @@
"Language": |
LANGUAGE
"Source on GitLab": |
SOURCE ON GITLAB
"Privacy Policy": |
PRIVACY POLICY
"Created by <1>Jeff Avallone</1>": |
CREATED BY <1>JEFF AVALLONE</1>
"Generated images licensed: <1><0></0></1>": |
GENERATED IMAGES LICENSED: <1><0></0></1>
"Creative Commons CC-BY-3.0 License": |
CREATIVE COMMONS CC-BY-3.0 LICENSE
"An error has occurred": |
AN ERROR HAS OCCURRED
"This error has been logged. You may also <1>fill out a report</1>.": |
THIS ERROR HAS BEEN LOGGED. YOU MAY ALSO <1>FILL OUT A REPORT</1>.
"Hello world": |
HELLO WORLD
"Privacy policy copy": |
<0>REGEXPER AND THE TOOLS USED TO CREATE IT ARE ALL OPEN SOURCE. If you are
concerned that the JavaScript being delivered is in any way malicious, please
inspect the source in the <1>GitLab repository</1>.</0>
<1>There are two data collection tools integrated in the app. These tools are
not used to collect personal information:</1>
<2>
<0><0>Google Analytics</0> is used to track browser usage data and
application performance. It is configured to anonymize the client IP
address.</0>
<1><0>Sentry.io</0> is a tool used to capture and report client-side
JavaScript errors. It is configured to not store the client IP address.</1>
</2>
<3>Regexper honors the browser <1>“Do Not Track”</1> setting and will not
enable these data collection tools if that setting is enabled. Also, most
popular ad blockers will prevent these tools from sending any tracking data.
Disabling or blocking these data collection tools will <3>not</3> impact the
performance of this app. The information collected by these tools is used to
monitor application performance, determine browser support, and collect error
reports.</3>
<4>Regexper is not supported by ad revenue or sales of any kind.</4>
"Page Not Found": |
PAGE NOT FOUND
"404 Page Not Found": |
404 PAGE NOT FOUND
"The page you have requested could not be found.": |
THE PAGE YOU HAVE REQUESTED COULD NOT BE FOUND.

View File

@ -1,2 +1,45 @@
"Language": |
Language
"Source on GitLab": |
Source on GitLab
"Privacy Policy": |
Privacy Policy
"Created by <1>Jeff Avallone</1>": |
Created by <1>Jeff Avallone</1>
"Generated images licensed: <1><0></0></1>": |
Generated images licensed: <1><0></0></1>
"Creative Commons CC-BY-3.0 License": |
Creative Commons CC-BY-3.0 License
"An error has occurred": |
An error has occurred
"This error has been logged. You may also <1>fill out a report</1>.": |
This error has been logged. You may also <1>fill out a report</1>.
"Hello world": |
Hello world
"Privacy policy copy": |
<0>Regexper and the tools used to create it are all open source. If you are
concerned that the JavaScript being delivered is in any way malicious, please
inspect the source in the <1>GitLab repository</1>.</0>
<1>There are two data collection tools integrated in the app. These tools are
not used to collect personal information:</1>
<2>
<0><0>Google Analytics</0> is used to track browser usage data and
application performance. It is configured to anonymize the client IP
address.</0>
<1><0>Sentry.io</0> is a tool used to capture and report client-side
JavaScript errors. It is configured to not store the client IP address.</1>
</2>
<3>Regexper honors the browser <1>“Do Not Track”</1> setting and will not
enable these data collection tools if that setting is enabled. Also, most
popular ad blockers will prevent these tools from sending any tracking data.
Disabling or blocking these data collection tools will <3>not</3> impact the
performance of this app. The information collected by these tools is used to
monitor application performance, determine browser support, and collect error
reports.</3>
<4>Regexper is not supported by ad revenue or sales of any kind.</4>
"Page Not Found": |
Page Not Found
"404 Page Not Found": |
404 Page Not Found
"The page you have requested could not be found.": |
The page you have requested could not be found.

View File

@ -1,13 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withNamespaces, Trans } from 'react-i18next';
import Metadata from 'components/Metadata';
import Message from 'components/Message';
const ErrorPage = () => <>
<Metadata title="Page Not Found" />
<Message type="error" heading="404 Page Not Found">
<p>The page you have requrested could not be found.</p>
export const ErrorPageImpl = ({ t }) => <>
<Metadata title={ t('Page Not Found') } />
<Message type="error" heading={ t('404 Page Not Found') }>
<p><Trans>The page you have requested could not be found.</Trans></p>
</Message>
</>;
export default ErrorPage;
ErrorPageImpl.propTypes = {
t: PropTypes.func.isRequired
};
export default withNamespaces()(ErrorPageImpl);

View File

@ -1,12 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import ErrorPage from 'pages/404';
import { mockT } from 'i18n';
import { ErrorPageImpl } from 'pages/404';
describe('Error Page', () => {
test('rendering', () => {
const component = shallow(
<ErrorPage />
<ErrorPageImpl t={ mockT } />
);
expect(component).toMatchSnapshot();
});

View File

@ -3,7 +3,9 @@
exports[`Error Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ErrorPage />,
Symbol(enzyme.__unrendered__): <ErrorPageImpl
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
@ -19,14 +21,16 @@ ShallowWrapper {
"props": Object {
"children": Array [
<Metadata
title="Page Not Found"
title="TRANSLATE(Page Not Found)"
/>,
<Message
heading="404 Page Not Found"
heading="TRANSLATE(404 Page Not Found)"
type="error"
>
<p>
The page you have requrested could not be found.
<WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>
</p>
</Message>,
],
@ -38,7 +42,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"title": "Page Not Found",
"title": "TRANSLATE(Page Not Found)",
},
"ref": null,
"rendered": null,
@ -50,9 +54,11 @@ ShallowWrapper {
"nodeType": "function",
"props": Object {
"children": <p>
The page you have requrested could not be found.
<WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>
</p>,
"heading": "404 Page Not Found",
"heading": "TRANSLATE(404 Page Not Found)",
"type": "error",
},
"ref": null,
@ -61,10 +67,22 @@ ShallowWrapper {
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "The page you have requrested could not be found.",
"children": <WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": "The page you have requrested could not be found.",
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "The page you have requested could not be found.",
},
"ref": null,
"rendered": "The page you have requested could not be found.",
"type": [Function],
},
"type": "p",
},
"type": [Function],
@ -80,14 +98,16 @@ ShallowWrapper {
"props": Object {
"children": Array [
<Metadata
title="Page Not Found"
title="TRANSLATE(Page Not Found)"
/>,
<Message
heading="404 Page Not Found"
heading="TRANSLATE(404 Page Not Found)"
type="error"
>
<p>
The page you have requrested could not be found.
<WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>
</p>
</Message>,
],
@ -99,7 +119,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"title": "Page Not Found",
"title": "TRANSLATE(Page Not Found)",
},
"ref": null,
"rendered": null,
@ -111,9 +131,11 @@ ShallowWrapper {
"nodeType": "function",
"props": Object {
"children": <p>
The page you have requrested could not be found.
<WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>
</p>,
"heading": "404 Page Not Found",
"heading": "TRANSLATE(404 Page Not Found)",
"type": "error",
},
"ref": null,
@ -122,10 +144,22 @@ ShallowWrapper {
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "The page you have requrested could not be found.",
"children": <WithMergedOptions(TransComponent)>
The page you have requested could not be found.
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": "The page you have requrested could not be found.",
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "The page you have requested could not be found.",
},
"ref": null,
"rendered": "The page you have requested could not be found.",
"type": [Function],
},
"type": "p",
},
"type": [Function],

View File

@ -3,7 +3,7 @@
exports[`Index Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <IndexPage />,
Symbol(enzyme.__unrendered__): <IndexPageImpl />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
@ -39,7 +39,9 @@ ShallowWrapper {
</Message>
</noscript>,
<div>
<WithMergedOptions(TransComponent)>
Hello world
</WithMergedOptions(TransComponent)>
</div>,
],
},
@ -156,11 +158,23 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Hello world
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Hello world",
},
"ref": null,
"rendered": "Hello world",
"type": [Function],
},
"type": "div",
},
],
@ -194,7 +208,9 @@ ShallowWrapper {
</Message>
</noscript>,
<div>
<WithMergedOptions(TransComponent)>
Hello world
</WithMergedOptions(TransComponent)>
</div>,
],
},
@ -311,11 +327,23 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <WithMergedOptions(TransComponent)>
Hello world
</WithMergedOptions(TransComponent)>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Hello world",
},
"ref": null,
"rendered": "Hello world",
"type": [Function],
},
"type": "div",
},
],

View File

@ -3,7 +3,9 @@
exports[`Privacy Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <PrivacyPage />,
Symbol(enzyme.__unrendered__): <PrivacyPageImpl
t={[Function]}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
@ -19,11 +21,14 @@ ShallowWrapper {
"props": Object {
"children": Array [
<Metadata
title="Privacy Policy"
title="TRANSLATE(Privacy Policy)"
/>,
<Message
heading="Privacy Policy"
heading="TRANSLATE(Privacy Policy)"
type="info"
>
<WithMergedOptions(TransComponent)
i18nKey="Privacy policy copy"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
@ -67,6 +72,7 @@ ShallowWrapper {
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</WithMergedOptions(TransComponent)>
</Message>,
],
},
@ -77,7 +83,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"title": "Privacy Policy",
"title": "TRANSLATE(Privacy Policy)",
},
"ref": null,
"rendered": null,
@ -87,6 +93,61 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <WithMergedOptions(TransComponent)
i18nKey="Privacy policy copy"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</WithMergedOptions(TransComponent)>,
"heading": "TRANSLATE(Privacy Policy)",
"type": "info",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<p>
@ -132,8 +193,7 @@ ShallowWrapper {
Regexper is not supported by ad revenue or sales of any kind.
</p>,
],
"heading": "Privacy Policy",
"type": "info",
"i18nKey": "Privacy policy copy",
},
"ref": null,
"rendered": Array [
@ -330,6 +390,8 @@ ShallowWrapper {
],
"type": [Function],
},
"type": [Function],
},
],
"type": Symbol(react.fragment),
},
@ -341,11 +403,14 @@ ShallowWrapper {
"props": Object {
"children": Array [
<Metadata
title="Privacy Policy"
title="TRANSLATE(Privacy Policy)"
/>,
<Message
heading="Privacy Policy"
heading="TRANSLATE(Privacy Policy)"
type="info"
>
<WithMergedOptions(TransComponent)
i18nKey="Privacy policy copy"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
@ -389,6 +454,7 @@ ShallowWrapper {
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</WithMergedOptions(TransComponent)>
</Message>,
],
},
@ -399,7 +465,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "function",
"props": Object {
"title": "Privacy Policy",
"title": "TRANSLATE(Privacy Policy)",
},
"ref": null,
"rendered": null,
@ -409,6 +475,61 @@ ShallowWrapper {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <WithMergedOptions(TransComponent)
i18nKey="Privacy policy copy"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</WithMergedOptions(TransComponent)>,
"heading": "TRANSLATE(Privacy Policy)",
"type": "info",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<p>
@ -454,8 +575,7 @@ ShallowWrapper {
Regexper is not supported by ad revenue or sales of any kind.
</p>,
],
"heading": "Privacy Policy",
"type": "info",
"i18nKey": "Privacy policy copy",
},
"ref": null,
"rendered": Array [
@ -652,6 +772,8 @@ ShallowWrapper {
],
"type": [Function],
},
"type": [Function],
},
],
"type": Symbol(react.fragment),
},

View File

@ -1,10 +1,11 @@
import React from 'react';
import { Link } from 'gatsby';
import { withNamespaces, Trans } from 'react-i18next';
import Metadata from 'components/Metadata';
import Message from 'components/Message';
const IndexPage = () => <>
export const IndexPageImpl = () => <>
<Metadata/>
<noscript>
<Message type="error" heading="JavaScript Required">
@ -13,7 +14,7 @@ const IndexPage = () => <>
please see the <Link to="/privacy">Privacy Policy</Link>.</p>
</Message>
</noscript>
<div>Hello world</div>
<div><Trans>Hello world</Trans></div>
</>;
export default IndexPage;
export default withNamespaces()(IndexPageImpl);

View File

@ -1,12 +1,12 @@
import React from 'react';
import { shallow } from 'enzyme';
import IndexPage from 'pages/index';
import { IndexPageImpl } from 'pages/index';
describe('Index Page', () => {
test('rendering', () => {
const component = shallow(
<IndexPage />
<IndexPageImpl />
);
expect(component).toMatchSnapshot();
});

View File

@ -1,11 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withNamespaces, Trans } from 'react-i18next';
import Metadata from 'components/Metadata';
import Message from 'components/Message';
const PrivacyPage = () => <>
<Metadata title="Privacy Policy" />
<Message type="info" heading="Privacy Policy">
export const PrivacyPageImpl = ({ t }) => <>
<Metadata title={ t('Privacy Policy') } />
<Message type="info" heading={ t('Privacy Policy') }>
<Trans i18nKey="Privacy policy copy">
<p>
Regexper and the tools used to create it are all open source. If you are
concerned that the JavaScript being delivered is in any way malicious,
@ -26,22 +29,28 @@ const PrivacyPage = () => <>
</li>
<li>
<b>Sentry.io</b> is a tool used to capture and report client-side
JavaScript errors. It is configured to not store the client IP address.
JavaScript errors. It is configured to not store the client IP
address.
</li>
</ul>
<p>
Regexper honors the browser <b>&ldquo;Do Not Track&rdquo;</b> setting and
will not enable these data collection tools if that setting is enabled.
Also, most popular ad blockers will prevent these tools from sending any
tracking data. Disabling or blocking these data collection tools
will <b>not</b> impact the performance of this app. The information
collected by these tools is used to monitor application performance,
determine browser support, and collect error reports.
Regexper honors the browser <b>&ldquo;Do Not Track&rdquo;</b> setting
and will not enable these data collection tools if that setting is
enabled. Also, most popular ad blockers will prevent these tools from
sending any tracking data. Disabling or blocking these data collection
tools will <b>not</b> impact the performance of this app. The
information collected by these tools is used to monitor application
performance, determine browser support, and collect error reports.
</p>
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</Trans>
</Message>
</>;
export default PrivacyPage;
PrivacyPageImpl.propTypes = {
t: PropTypes.func.isRequired
};
export default withNamespaces()(PrivacyPageImpl);

View File

@ -1,12 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import PrivacyPage from 'pages/privacy';
import { mockT } from 'i18n';
import { PrivacyPageImpl } from 'pages/privacy';
describe('Privacy Page', () => {
test('rendering', () => {
const component = shallow(
<PrivacyPage />
<PrivacyPageImpl t={ mockT } />
);
expect(component).toMatchSnapshot();
});