Skip to content

Commit 832e247

Browse files
committed
update example
Signed-off-by: Dmitriy Nevzorov <[email protected]>
1 parent 2c5ae2f commit 832e247

File tree

11 files changed

+813
-1422
lines changed

11 files changed

+813
-1422
lines changed

example/babel-extract.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const {defaultLanguage} = require('./languages');
22

3+
process.env.NODE_ENV = 'test';
4+
35
module.exports = {
46
presets: ['babel-preset-gatsby'],
57
plugins: [

example/gatsby-config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
languages,
3838
defaultLanguage,
3939
path: `${__dirname}/locales`,
40-
siteUrl: 'https://5ecd0801489011000849a7db--kind-lichterman-5edcb4.netlify.app',
40+
siteUrl: 'https://kind-lichterman-5edcb4.netlify.app',
4141
i18nextOptions: {
4242
debug: true,
4343
lowerCaseLng: true,
@@ -47,7 +47,13 @@ module.exports = {
4747
},
4848
keySeparator: false,
4949
nsSeparator: false
50-
}
50+
},
51+
pages: [
52+
{
53+
matchPath: '/ignored-page',
54+
languages: ['en']
55+
}
56+
]
5157
}
5258
},
5359
{

example/locales/de/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"Go back to the homepage": "Zurück zur Homepage",
1010
"Hi people": "Hallo Leute",
1111
"Welcome to your new Gatsby site.": "Willkommen auf Ihrer neuen Gatsby Website.",
12-
"You just hit a route that doesn't exist... the sadness.": "Du hast gerade eine Route getroffen, die nicht existiert... die Traurigkeit."
12+
"You just hit a route that doesn't exist... the sadness.": "Du hast gerade eine Route getroffen, die nicht existiert... die Traurigkeit.",
13+
"Go to ignored page": "Gehe zur ignorierten Seite"
1314
}

example/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"404: Not found": "404: Not found",
33
"Go back to the homepage": "Go back to the homepage",
4+
"Go to ignored page": "Go to ignored page",
45
"Go to page 2": "Go to page 2",
56
"Hi people": "Hi people",
67
"Home": "Home",

example/locales/es/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"Now go build something great.": "Ahora ve a construir algo grande.",
1010
"Welcome to your new Gatsby site.": "Bienvenido a su nuevo sitio de Gatsby.",
1111
"Welcome to page 2": "Bienvenido a la página 2",
12-
"You just hit a route that doesn't exist... the sadness.": "Acabas de llegar a una ruta que no existe... la tristeza."
12+
"You just hit a route that doesn't exist... the sadness.": "Acabas de llegar a una ruta que no existe... la tristeza.",
13+
"Go to ignored page": "Ir a la página ignorada"
1314
}

example/locales/fr/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"Hi people": "Salut les gens",
1010
"Now go build something great.": "Maintenant va construire quelque chose de génial.",
1111
"Welcome to page 2": "Bienvenue à la page 2",
12-
"You just hit a route that doesn't exist... the sadness.": "Tu viens d'emprunter une route qui n'existe pas... la tristesse."
12+
"You just hit a route that doesn't exist... the sadness.": "Tu viens d'emprunter une route qui n'existe pas... la tristesse.",
13+
"Go to ignored page": "Aller à la page ignorée"
1314
}

example/locales/it/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"Go to page 2": "Vai alla pagina 2",
1010
"Go back to the homepage": "Torna alla homepage",
1111
"Welcome to page 2": "Benvenuto a pagina 2",
12-
"You just hit a route that doesn't exist... the sadness.": "Hai appena fatto una strada che non esiste... la tristezza."
12+
"You just hit a route that doesn't exist... the sadness.": "Hai appena fatto una strada che non esiste... la tristezza.",
13+
"Go to ignored page": "Vai alla pagina ignorata"
1314
}

example/package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
"version": "0.1.0",
66
"author": "Kyle Mathews <[email protected]>",
77
"dependencies": {
8-
"gatsby": "^2.23.11",
9-
"gatsby-image": "^2.4.9",
10-
"gatsby-plugin-manifest": "^2.4.14",
11-
"gatsby-plugin-offline": "^3.2.13",
12-
"gatsby-plugin-react-helmet": "^3.3.6",
13-
"gatsby-plugin-react-i18next": "^0.0.22",
14-
"gatsby-plugin-sharp": "^2.6.14",
15-
"gatsby-plugin-sitemap": "^2.4.7",
16-
"gatsby-source-filesystem": "^2.3.14",
17-
"gatsby-transformer-sharp": "^2.5.7",
18-
"i18next": "^19.5.1",
8+
"gatsby": "^2.24.23",
9+
"gatsby-image": "^2.4.14",
10+
"gatsby-plugin-manifest": "^2.4.21",
11+
"gatsby-plugin-offline": "^3.2.21",
12+
"gatsby-plugin-react-helmet": "^3.3.10",
13+
"gatsby-plugin-react-i18next": "^0.0.24",
14+
"gatsby-plugin-sharp": "^2.6.24",
15+
"gatsby-plugin-sitemap": "^2.4.11",
16+
"gatsby-source-filesystem": "^2.3.23",
17+
"gatsby-transformer-sharp": "^2.5.12",
18+
"i18next": "^19.6.3",
1919
"prop-types": "^15.7.2",
2020
"react": "^16.12.0",
2121
"react-dom": "^16.12.0",
2222
"react-helmet": "^6.1.0",
2323
"react-i18next": "^11.7.0"
2424
},
2525
"devDependencies": {
26-
"@babel/cli": "^7.10.3",
27-
"@babel/core": "^7.10.3",
28-
"aws-sdk": "^2.705.0",
26+
"@babel/cli": "^7.10.5",
27+
"@babel/core": "^7.11.0",
28+
"aws-sdk": "^2.725.0",
2929
"babel-plugin-i18next-extract": "^0.7.2",
30+
"babel-preset-gatsby": "^0.5.4",
3031
"mkdirp": "^1.0.4",
3132
"prettier": "2.0.5"
3233
},

example/src/pages/ignored-page.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import Layout from '../components/layout';
3+
import SEO from '../components/seo';
4+
import {Link, useI18next} from 'gatsby-plugin-react-i18next';
5+
6+
const IgnoredPage = (props) => {
7+
const context = useI18next();
8+
console.log(context);
9+
return (
10+
<Layout>
11+
<SEO title="Ignored page" />
12+
<h1>Ignored page</h1>
13+
<p>This page does not have language prefix</p>
14+
<Link to="/">Go back to the homepage</Link>
15+
</Layout>
16+
);
17+
};
18+
19+
export default IgnoredPage;

example/src/pages/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import {Link, Trans, useTranslation} from 'gatsby-plugin-react-i18next';
3+
import {Link as GatsbyLink} from 'gatsby';
34
import Layout from '../components/layout';
45
import Image from '../components/image';
56
import SEO from '../components/seo';
@@ -21,9 +22,16 @@ const IndexPage = () => {
2122
<div style={{maxWidth: `300px`, marginBottom: `1.45rem`}}>
2223
<Image />
2324
</div>
24-
<Link to="/page-2/">
25-
<Trans>Go to page 2</Trans>
26-
</Link>
25+
<p>
26+
<Link to="/page-2/">
27+
<Trans>Go to page 2</Trans>
28+
</Link>
29+
</p>
30+
<p>
31+
<GatsbyLink to="/ignored-page">
32+
<Trans>Go to ignored page</Trans>
33+
</GatsbyLink>
34+
</p>
2735
</Layout>
2836
);
2937
};

0 commit comments

Comments
 (0)