next-i18next-static-site 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
<p>i18next solution for static sites build with Next.js (static HTML export / <code>next export</code>).</p>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
|
-
## i18next solution for Next.js
|
|
7
|
-
|
|
8
6
|
This package brings you `react-i18next` and `i18next` to your static sites build with the `next export` future from Next.js.
|
|
9
7
|
|
|
10
8
|
- 🗲 Translation is already rendered (SSG), client will receive the final translated site.
|
|
11
|
-
- 🚀 Automatic browser language detection.
|
|
12
|
-
- 🍪 Cookie stores the client language.
|
|
13
9
|
- 🔥 Hot reload works also when you update your locale (translation) files.
|
|
10
|
+
- 🚀 Automatic browser language detection can be realized.
|
|
11
|
+
- 🍪 Cookie stores the client language.
|
|
14
12
|
|
|
15
13
|
## Installation
|
|
16
14
|
|
|
@@ -18,10 +16,6 @@ This package brings you `react-i18next` and `i18next` to your static sites build
|
|
|
18
16
|
npm install --save next-i18next-static-site
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
## Configuration
|
|
22
|
-
|
|
23
|
-
You have to add a few environment variables to your `next.config.js`.
|
|
24
|
-
|
|
25
19
|
## Usage
|
|
26
20
|
|
|
27
21
|
Set the supported languages and the namespaces in your `next.config.js`:
|
|
@@ -98,3 +92,7 @@ export default App;
|
|
|
98
92
|
Now you are able to use `useTranslation`, `withTranslation`, `Translation` and `Trans` directly from `react-i18next` or from `next-i18next-static-site`.
|
|
99
93
|
|
|
100
94
|
> The [example Next.js site](https://github.com/xairoo/next-i18next-static-site/tree/main/apps/web-ts) provides a `Link` and `LinkText` (used for `Trans`) component and als a custom `404` page.
|
|
95
|
+
|
|
96
|
+
### Language detection
|
|
97
|
+
|
|
98
|
+
Please check the example [pages/index.tsx](https://github.com/xairoo/next-i18next-static-site/blob/main/examples/web-ts/pages/index.tsx). It contains a simple language detection and redirect solution.
|
package/dist/index.js
CHANGED
|
@@ -129,17 +129,17 @@ var I18nProvider = (props) => {
|
|
|
129
129
|
(0, import_react.useEffect)(() => {
|
|
130
130
|
i18n2.services.resourceStore.data = props.i18n.locales;
|
|
131
131
|
i18n2.changeLanguage(language);
|
|
132
|
-
}, [props.i18n.locales]);
|
|
132
|
+
}, [i18n2, language, props.i18n.locales]);
|
|
133
133
|
(0, import_react.useEffect)(() => {
|
|
134
134
|
loaded = true;
|
|
135
135
|
i18n2.changeLanguage(language);
|
|
136
|
-
}, [language]);
|
|
136
|
+
}, [i18n2, language]);
|
|
137
137
|
(0, import_react.useEffect)(() => {
|
|
138
138
|
const hasWindow = typeof window !== "undefined";
|
|
139
139
|
if (hasWindow && options.allowHydration) {
|
|
140
140
|
setHydration(true);
|
|
141
141
|
}
|
|
142
|
-
}, []);
|
|
142
|
+
}, [options.allowHydration]);
|
|
143
143
|
return hydration ? props.children : null;
|
|
144
144
|
};
|
|
145
145
|
function getAllLanguageSlugs() {
|
package/dist/index.mjs
CHANGED
|
@@ -92,17 +92,17 @@ var I18nProvider = (props) => {
|
|
|
92
92
|
useEffect(() => {
|
|
93
93
|
i18n2.services.resourceStore.data = props.i18n.locales;
|
|
94
94
|
i18n2.changeLanguage(language);
|
|
95
|
-
}, [props.i18n.locales]);
|
|
95
|
+
}, [i18n2, language, props.i18n.locales]);
|
|
96
96
|
useEffect(() => {
|
|
97
97
|
loaded = true;
|
|
98
98
|
i18n2.changeLanguage(language);
|
|
99
|
-
}, [language]);
|
|
99
|
+
}, [i18n2, language]);
|
|
100
100
|
useEffect(() => {
|
|
101
101
|
const hasWindow = typeof window !== "undefined";
|
|
102
102
|
if (hasWindow && options.allowHydration) {
|
|
103
103
|
setHydration(true);
|
|
104
104
|
}
|
|
105
|
-
}, []);
|
|
105
|
+
}, [options.allowHydration]);
|
|
106
106
|
return hydration ? props.children : null;
|
|
107
107
|
};
|
|
108
108
|
function getAllLanguageSlugs() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-i18next-static-site",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "i18next solution for static sites build with Next.js (static HTML export / next export)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
"build": "rm -rf dist && mkdir dist && tsup src/index.tsx --format esm,cjs --dts --external react",
|
|
29
29
|
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts",
|
|
30
30
|
"lint": "TIMING=1 eslint \"**/*.ts*\"",
|
|
31
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
31
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
32
|
+
"release": "release-it"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/react": "^17.0.37",
|
|
35
36
|
"@types/react-dom": "^17.0.11",
|
|
36
37
|
"eslint": "^7.32.0",
|
|
37
38
|
"eslint-config-custom": "*",
|
|
39
|
+
"release-it": "^15.5.0",
|
|
38
40
|
"tsconfig": "*",
|
|
39
41
|
"typescript": "^4.5.2"
|
|
40
42
|
},
|
|
@@ -42,8 +44,8 @@
|
|
|
42
44
|
"@types/js-cookie": "^3.0.2",
|
|
43
45
|
"i18next": "^21.10.0",
|
|
44
46
|
"js-cookie": "^3.0.1",
|
|
45
|
-
"react": "^18.2.0",
|
|
46
47
|
"next": "^13.0.0",
|
|
48
|
+
"react": "^18.2.0",
|
|
47
49
|
"react-i18next": "^11.18.6",
|
|
48
50
|
"tsup": "^6.3.0"
|
|
49
51
|
},
|