next-i18next 4.3.0 → 4.5.0
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 +2 -12
- package/dist/commonjs/create-i18next-client.js +5 -5
- package/dist/commonjs/index.js +0 -4
- package/dist/commonjs/middlewares/next-i18next-middleware.js +2 -2
- package/dist/es/create-i18next-client.js +5 -5
- package/dist/es/index.js +0 -4
- package/dist/es/middlewares/next-i18next-middleware.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# next-i18next
|
|
2
2
|
[](https://badge.fury.io/js/next-i18next)
|
|
3
3
|
[](https://circleci.com/gh/isaachinman/next-i18next)
|
|
4
|
-
[](https://david-dm.org/isaachinman/next-i18next)
|
|
5
4
|
[](https://packagequality.com/#?package=next-i18next)
|
|
6
5
|
|
|
7
6
|
**The easiest way to translate your NextJs apps.**
|
|
@@ -51,20 +50,12 @@ If translations are not found in `config.localePath` or `public/static/locales`
|
|
|
51
50
|
The default export of `next-i18next` is a class constructor, into which you pass your config options. The resulting class has all the methods you will need to translate your app:
|
|
52
51
|
|
|
53
52
|
```jsx
|
|
54
|
-
|
|
53
|
+
const NextI18Next = require('next-i18next').default
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
module.exports = new NextI18Next({
|
|
57
56
|
defaultLanguage: 'en',
|
|
58
57
|
otherLanguages: ['de']
|
|
59
58
|
})
|
|
60
|
-
|
|
61
|
-
export default NextI18NextInstance
|
|
62
|
-
|
|
63
|
-
/* Optionally, export class methods as named exports */
|
|
64
|
-
export const {
|
|
65
|
-
appWithTranslation,
|
|
66
|
-
withTranslation,
|
|
67
|
-
} = NextI18NextInstance
|
|
68
59
|
```
|
|
69
60
|
|
|
70
61
|
[A full list of options can be seen here](#options).
|
|
@@ -259,7 +250,6 @@ _This table contains options which are specific to next-i18next. All other [i18n
|
|
|
259
250
|
## Notes
|
|
260
251
|
|
|
261
252
|
- [`next export` will result in a _client-side only_ React application.](https://github.com/isaachinman/next-i18next/issues/10)
|
|
262
|
-
- [We cannot support koa until a 1:1 replacement for `i18next-express-middleware` exists](https://github.com/isaachinman/next-i18next/issues/9).
|
|
263
253
|
- [Serverless (e.g. Now 2.0) is not currently supported](https://github.com/isaachinman/next-i18next/issues/274).
|
|
264
254
|
- [To add a `lang` attribute to your top-level html DOM node, you must create a `_document.js` file.](https://github.com/isaachinman/next-i18next/issues/20#issuecomment-443461652)
|
|
265
255
|
- [Localising `next/head` requires special consideration due to NextJs internals](https://github.com/isaachinman/next-i18next/issues/251#issuecomment-479421852).
|
|
@@ -15,7 +15,7 @@ var _detectNode = _interopRequireDefault(require("detect-node"));
|
|
|
15
15
|
|
|
16
16
|
var _i18next = _interopRequireDefault(require("i18next"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _cjs = _interopRequireDefault(require("i18next-http-backend/cjs"));
|
|
19
19
|
|
|
20
20
|
var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
|
|
21
21
|
|
|
@@ -24,10 +24,10 @@ var _default = function _default(config) {
|
|
|
24
24
|
|
|
25
25
|
if (!_i18next["default"].isInitialized) {
|
|
26
26
|
if (_detectNode["default"]) {
|
|
27
|
-
var
|
|
28
|
-
var i18nextMiddleware = eval("require('i18next-
|
|
27
|
+
var i18nextFSBackend = eval("require('i18next-fs-backend/cjs')");
|
|
28
|
+
var i18nextMiddleware = eval("require('i18next-http-middleware/cjs')");
|
|
29
29
|
|
|
30
|
-
_i18next["default"].use(
|
|
30
|
+
_i18next["default"].use(i18nextFSBackend);
|
|
31
31
|
|
|
32
32
|
if (config.serverLanguageDetection) {
|
|
33
33
|
var serverDetectors = new i18nextMiddleware.LanguageDetector();
|
|
@@ -38,7 +38,7 @@ var _default = function _default(config) {
|
|
|
38
38
|
_i18next["default"].use(serverDetectors);
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
|
-
_i18next["default"].use(
|
|
41
|
+
_i18next["default"].use(_cjs["default"]);
|
|
42
42
|
|
|
43
43
|
if (config.browserLanguageDetection) {
|
|
44
44
|
var browserDetectors = new _i18nextBrowserLanguagedetector["default"]();
|
package/dist/commonjs/index.js
CHANGED
|
@@ -54,10 +54,6 @@ var NextI18Next = function NextI18Next(userConfig) {
|
|
|
54
54
|
this.consoleMessage = _utils.consoleMessage.bind(this);
|
|
55
55
|
/* Validation */
|
|
56
56
|
|
|
57
|
-
if (this.config.otherLanguages.length <= 0) {
|
|
58
|
-
throw new Error('To properly initialise a next-i18next instance you must provide one or more locale codes in config.otherLanguages.');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
57
|
this.withNamespaces = function () {
|
|
62
58
|
throw new Error('next-i18next has upgraded to react-i18next v10 - please rename withNamespaces to withTranslation.');
|
|
63
59
|
};
|
|
@@ -25,7 +25,7 @@ require("core-js/modules/es6.string.starts-with");
|
|
|
25
25
|
|
|
26
26
|
require("core-js/modules/es6.array.is-array");
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _cjs = _interopRequireDefault(require("i18next-http-middleware/cjs"));
|
|
29
29
|
|
|
30
30
|
var _pathMatch = _interopRequireDefault(require("path-match"));
|
|
31
31
|
|
|
@@ -68,7 +68,7 @@ function _default(nexti18next) {
|
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
middleware.push(
|
|
71
|
+
middleware.push(_cjs["default"].handle(i18n));
|
|
72
72
|
/*
|
|
73
73
|
This does the locale subpath work
|
|
74
74
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import isNode from 'detect-node';
|
|
2
2
|
import i18n from 'i18next';
|
|
3
|
-
import
|
|
3
|
+
import i18nextHTTPBackend from 'i18next-http-backend/cjs';
|
|
4
4
|
import I18nextBrowserLanguageDetector from 'i18next-browser-languagedetector';
|
|
5
5
|
export default (config => {
|
|
6
6
|
let initPromise;
|
|
7
7
|
|
|
8
8
|
if (!i18n.isInitialized) {
|
|
9
9
|
if (isNode) {
|
|
10
|
-
const
|
|
11
|
-
const i18nextMiddleware = eval("require('i18next-
|
|
12
|
-
i18n.use(
|
|
10
|
+
const i18nextFSBackend = eval("require('i18next-fs-backend/cjs')");
|
|
11
|
+
const i18nextMiddleware = eval("require('i18next-http-middleware/cjs')");
|
|
12
|
+
i18n.use(i18nextFSBackend);
|
|
13
13
|
|
|
14
14
|
if (config.serverLanguageDetection) {
|
|
15
15
|
const serverDetectors = new i18nextMiddleware.LanguageDetector();
|
|
@@ -17,7 +17,7 @@ export default (config => {
|
|
|
17
17
|
i18n.use(serverDetectors);
|
|
18
18
|
}
|
|
19
19
|
} else {
|
|
20
|
-
i18n.use(
|
|
20
|
+
i18n.use(i18nextHTTPBackend);
|
|
21
21
|
|
|
22
22
|
if (config.browserLanguageDetection) {
|
|
23
23
|
const browserDetectors = new I18nextBrowserLanguageDetector();
|
package/dist/es/index.js
CHANGED
|
@@ -13,10 +13,6 @@ export default class NextI18Next {
|
|
|
13
13
|
this.consoleMessage = consoleMessage.bind(this);
|
|
14
14
|
/* Validation */
|
|
15
15
|
|
|
16
|
-
if (this.config.otherLanguages.length <= 0) {
|
|
17
|
-
throw new Error('To properly initialise a next-i18next instance you must provide one or more locale codes in config.otherLanguages.');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
this.withNamespaces = () => {
|
|
21
17
|
throw new Error('next-i18next has upgraded to react-i18next v10 - please rename withNamespaces to withTranslation.');
|
|
22
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import i18nextMiddleware from 'i18next-
|
|
1
|
+
import i18nextMiddleware from 'i18next-http-middleware/cjs';
|
|
2
2
|
import pathMatch from 'path-match';
|
|
3
3
|
import { addSubpath, lngFromReq, redirectWithoutCache, removeSubpath, subpathFromLng, subpathIsPresent, subpathIsRequired } from '../utils';
|
|
4
4
|
const route = pathMatch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-i18next",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"repository": "git@github.com:isaachinman/next-i18next.git",
|
|
5
5
|
"author": "Isaac Hinman <isaac@isaachinman.com>",
|
|
6
6
|
"funding": {
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@babel/preset-env": "^7.5.5",
|
|
70
70
|
"@babel/preset-react": "^7.0.0",
|
|
71
71
|
"@babel/preset-typescript": "^7.3.3",
|
|
72
|
-
"@types/express": "^4.16.1",
|
|
73
72
|
"@types/jest": "^24.0.16",
|
|
74
73
|
"@types/jest-environment-puppeteer": "^4.0.0",
|
|
75
74
|
"@types/react": "^16.8.4",
|
|
@@ -100,14 +99,15 @@
|
|
|
100
99
|
"typescript": "^3.5.3"
|
|
101
100
|
},
|
|
102
101
|
"dependencies": {
|
|
102
|
+
"@types/express": "^4.16.1",
|
|
103
103
|
"core-js": "^2",
|
|
104
104
|
"detect-node": "^2.0.4",
|
|
105
105
|
"hoist-non-react-statics": "^3.2.0",
|
|
106
106
|
"i18next": "^19.0.3",
|
|
107
107
|
"i18next-browser-languagedetector": "^4.0.0",
|
|
108
|
-
"i18next-
|
|
109
|
-
"i18next-
|
|
110
|
-
"i18next-
|
|
108
|
+
"i18next-fs-backend": "^1.0.2",
|
|
109
|
+
"i18next-http-backend": "^1.0.8",
|
|
110
|
+
"i18next-http-middleware": ">=1.0.2",
|
|
111
111
|
"path-match": "^1.2.4",
|
|
112
112
|
"prop-types": "^15.6.2",
|
|
113
113
|
"react-i18next": "^11.0.0",
|
|
@@ -117,4 +117,4 @@
|
|
|
117
117
|
"next": ">= 7.0.0",
|
|
118
118
|
"react": ">= 16.8.0"
|
|
119
119
|
}
|
|
120
|
-
}
|
|
120
|
+
}
|