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
+50-20Lines changed: 50 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Easily translate your Gatsby website into multiple languages.
5
5
## Features
6
6
7
7
- Seamless integration with [react-i18next](https://react.i18next.com/) - a powerful internationalization framework for React.
8
-
-No extra graphql queries to fetch translations, everything is done automatically.
8
+
-Code splitting. Load translations for each page separately.
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
11
- SEO friendly
@@ -17,7 +17,7 @@ When you build multilingual sites, Google recommends using different URLs for ea
17
17
18
18
## :boom: Breaking change since v0.0.27
19
19
20
-
As of v0.0.28, language JSON resources should be loaded by `gatsby-source-filesystem` plugin and than fetched by GraphQL query. It enables incremental build and hot-reload as language JSON files change.
20
+
As of v0.0.28, language JSON resources should be loaded by `gatsby-source-filesystem` plugin and then fetched by GraphQL query. It enables incremental build and hot-reload as language JSON files change.
21
21
22
22
Users who have loaded language JSON files using `path` option will be affected. Please check configuration example on below.
23
23
@@ -55,8 +55,7 @@ plugins: [
55
55
resolve:`gatsby-source-filesystem`,
56
56
options: {
57
57
path:`${__dirname}/locales`,
58
-
name:`locale`,
59
-
ignore: [`**/\.*`, `**/*~`]
58
+
name:`locale`
60
59
}
61
60
},
62
61
{
@@ -113,8 +112,8 @@ For example:
113
112
114
113
```
115
114
|-- en
116
-
|-- header.json
117
-
|-- footer.json
115
+
|-- common.json
116
+
|-- index.json
118
117
```
119
118
120
119
The default namespace is `translation`. [Read more about i18next namespaces](https://www.i18next.com/principles/namespaces)
@@ -382,35 +381,38 @@ pages: [
382
381
];
383
382
```
384
383
385
-
## How to fetch language specific data
384
+
## How to fetch translations of specific namespaces only
386
385
387
-
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:
386
+
You can use `ns` and `language`field in gatsby page queries to fetch specific namespaces that are being used in the page. This will be useful when you have several big pages with lots of translations.
## How to fetch translations of specific namespaces only
404
+
Note that in this case only files `common.json` and `index.json` will be loaded.
405
+
This plugin will automatically add all loaded namespaces as fallback namespaces so if you don't specify a namespace in your translations they will still work.
400
406
401
-
You can use `ns` and `language` field in gatsby page queries to fetch specific namespaces that are being used in the page. This will be useful when you have several big pages with lots of translations.
407
+
## How to fetch language specific data
408
+
409
+
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:
### Automatically translate to different languages
528
558
529
559
After your messages had been extracted you can use [AWS Translate](https://aws.amazon.com/translate/) to automatically translate messages to different languages.
0 commit comments