You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Easily translate your Gatsby website into multiple languages.
8
8
- No extra graphql queries to fetch translations, everything is done automatically.
9
9
- Automatic redirection based on the user's preferred language in browser provided by [browser-lang](https://github.com/wiziple/browser-lang).
10
10
- Support multi-language url routes in a single page component. You don't have to create separate pages such as `pages/en/index.js` or `pages/es/index.js`.
11
+
- SEO friendly
11
12
- Support for [gatsby-plugin-layout](https://www.gatsbyjs.org/packages/gatsby-plugin-layout/)
12
13
13
14
## Why?
@@ -263,6 +264,20 @@ This react hook returns `I18nextContext`, object and additional helper functions
263
264
const {t} =useI18next();
264
265
```
265
266
267
+
## How to fetch language specific data
268
+
269
+
You can use `language` variable in gatsby page queries to fetch additional data for each language. For example if you're using [gatsby-transformer-json](https://www.gatsbyjs.org/packages/gatsby-transformer-json/) your query might look like:
270
+
271
+
```typescript
272
+
exportconst query =graphql`
273
+
query($language: String!) {
274
+
dataJson(language: {eq: $language}) {
275
+
...DataFragment
276
+
}
277
+
}
278
+
`;
279
+
```
280
+
266
281
## How to extract translations from pages
267
282
268
283
You can use [babel-plugin-i18next-extract](https://i18next-extract.netlify.app) automatically extract translations inside `t` function and `Trans` component from you pages and save them in JSON.
0 commit comments