Skip to content

Commit 0fbf130

Browse files
committed
improve README.md
Signed-off-by: Dmitriy Nevzorov <jimmy.lugat@gmail.com>
1 parent 76d41de commit 0fbf130

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Easily translate your Gatsby website into multiple languages.
88
- No extra graphql queries to fetch translations, everything is done automatically.
99
- Automatic redirection based on the user's preferred language in browser provided by [browser-lang](https://github.com/wiziple/browser-lang).
1010
- 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
1112
- Support for [gatsby-plugin-layout](https://www.gatsbyjs.org/packages/gatsby-plugin-layout/)
1213

1314
## Why?
@@ -263,6 +264,20 @@ This react hook returns `I18nextContext`, object and additional helper functions
263264
const {t} = useI18next();
264265
```
265266

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+
export const query = graphql`
273+
query($language: String!) {
274+
dataJson(language: {eq: $language}) {
275+
...DataFragment
276+
}
277+
}
278+
`;
279+
```
280+
266281
## How to extract translations from pages
267282

268283
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

Comments
 (0)