Localize 404 page

This commit is contained in:
Kevin Kandlbinder 2021-11-07 18:54:13 +00:00 committed by GitHub
parent 7894afe62c
commit b7d9e71259
3 changed files with 34 additions and 5 deletions

View file

@ -84,5 +84,10 @@
}, },
"sections": "Rubriken", "sections": "Rubriken",
"posts": "Beiträge" "posts": "Beiträge"
},
"not_found": {
"title": "Nicht Gefunden",
"titleExt": "Seite Nicht Gefunden",
"text": "Ups... Diese Seite existiert nicht, also gehen wir am besten <1>zurück zur Startseite</1> und probieren es nochmal."
} }
} }

View file

@ -84,5 +84,10 @@
}, },
"sections": "Sections", "sections": "Sections",
"posts": "Posts" "posts": "Posts"
},
"not_found": {
"title": "Not Found",
"titleExt": "Page Not Found",
"text": "Whoops... That page doesn't exist, so you may as well <1>go home</1>."
} }
} }

View file

@ -1,16 +1,21 @@
import * as React from "react"; import * as React from "react";
import { Link } from "gatsby-plugin-react-i18next"; import { Link, useTranslation, Trans } from "gatsby-plugin-react-i18next";
import Layout from "../layouts/default"; import Layout from "../layouts/default";
import { graphql } from "gatsby";
const NotFoundPage = () => { const NotFoundPage = () => {
const { t } = useTranslation();
return ( return (
<Layout title="Not found"> <Layout title={t("not_found.title")}>
<section> <section>
<article> <article>
<h1>Page not found</h1> <h1>{t("not_found.titleExt")}</h1>
<p> <p>
Whoops... That page doesn&apos;t exist, so you may as <Trans
well <Link to="/">go home</Link>. i18nKey="not_found.text"
components={{ 1: <Link to="/" /> }}
/>
</p> </p>
</article> </article>
</section> </section>
@ -18,4 +23,18 @@ const NotFoundPage = () => {
); );
}; };
export const query = graphql`
query ($language: String) {
locales: allLocale(filter: { language: { eq: $language } }) {
edges {
node {
ns
data
language
}
}
}
}
`;
export default NotFoundPage; export default NotFoundPage;