next-i18next 5.0.0-beta.1 → 5.0.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/.eslintignore +2 -1
- package/.eslintrc +18 -6
- package/README.md +19 -50
- package/{.babelrc → babel.config.json} +10 -6
- package/dist/commonjs/components/Link.js +2 -6
- package/dist/commonjs/components/NextStaticProvider.js +1 -5
- package/dist/commonjs/components/index.js +0 -2
- package/dist/commonjs/config/create-config.js +29 -25
- package/dist/commonjs/config/default-config.js +1 -3
- package/dist/commonjs/create-client/browser.js +47 -0
- package/dist/commonjs/create-client/node.js +47 -0
- package/dist/commonjs/create-client/package.json +5 -0
- package/dist/commonjs/hocs/app-with-translation.js +44 -48
- package/dist/commonjs/hocs/index.js +0 -2
- package/dist/commonjs/hocs/with-internals.js +2 -6
- package/dist/commonjs/index.js +3 -9
- package/dist/commonjs/middlewares/index.js +0 -2
- package/dist/commonjs/middlewares/next-i18next-middleware.js +7 -9
- package/dist/commonjs/router/index.js +0 -2
- package/dist/commonjs/router/wrap-router.js +4 -4
- package/dist/commonjs/utils/add-subpath.js +3 -3
- package/dist/commonjs/utils/console-message.js +11 -17
- package/dist/commonjs/utils/generate-rewrites.js +3 -9
- package/dist/commonjs/utils/index.js +0 -2
- package/dist/commonjs/utils/is-server.js +0 -2
- package/dist/commonjs/utils/lng-from-req.js +5 -7
- package/dist/commonjs/utils/lng-path-corrector.js +13 -15
- package/dist/commonjs/utils/lngs-to-load.js +13 -11
- package/dist/commonjs/utils/redirect-without-cache.js +0 -2
- package/dist/commonjs/utils/remove-subpath.js +3 -3
- package/dist/commonjs/utils/subpath-from-lng.js +0 -2
- package/dist/commonjs/utils/subpath-is-present.js +1 -3
- package/dist/commonjs/utils/subpath-is-required.js +0 -2
- package/dist/es/components/Link.js +2 -2
- package/dist/es/config/create-config.js +13 -13
- package/dist/es/config/default-config.js +1 -1
- package/dist/es/create-client/browser.js +24 -0
- package/dist/es/create-client/node.js +24 -0
- package/dist/es/create-client/package.json +5 -0
- package/dist/es/hocs/app-with-translation.js +2 -2
- package/dist/es/hocs/with-internals.js +1 -1
- package/dist/es/index.js +1 -5
- package/dist/es/middlewares/next-i18next-middleware.js +1 -1
- package/package.json +22 -22
- package/types.d.ts +1 -0
- package/dist/commonjs/create-i18next-client.js +0 -65
- package/dist/es/create-i18next-client.js +0 -37
package/.eslintignore
CHANGED
package/.eslintrc
CHANGED
|
@@ -13,9 +13,15 @@
|
|
|
13
13
|
"browser": true
|
|
14
14
|
},
|
|
15
15
|
"rules": {
|
|
16
|
-
"@typescript-eslint/indent": [
|
|
16
|
+
"@typescript-eslint/indent": [
|
|
17
|
+
"error",
|
|
18
|
+
2
|
|
19
|
+
],
|
|
17
20
|
"semi": "off",
|
|
18
|
-
"@typescript-eslint/semi": [
|
|
21
|
+
"@typescript-eslint/semi": [
|
|
22
|
+
"error",
|
|
23
|
+
"never"
|
|
24
|
+
],
|
|
19
25
|
"@typescript-eslint/no-var-requires": 0,
|
|
20
26
|
"@typescript-eslint/no-explicit-any": 0,
|
|
21
27
|
"@typescript-eslint/explicit-function-return-type": 0,
|
|
@@ -33,11 +39,17 @@
|
|
|
33
39
|
"react/display-name": 0,
|
|
34
40
|
"react/jsx-filename-extension": 0,
|
|
35
41
|
"react/prefer-stateless-function": 0,
|
|
42
|
+
"react/react-in-jsx-scope": 0,
|
|
36
43
|
"no-restricted-syntax": 0,
|
|
37
44
|
"no-useless-escape": 0,
|
|
38
|
-
"no-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
"no-console": [
|
|
46
|
+
"error",
|
|
47
|
+
{
|
|
48
|
+
"allow": [
|
|
49
|
+
"warn",
|
|
50
|
+
"error"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
42
54
|
}
|
|
43
55
|
}
|
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.**
|
|
@@ -14,7 +13,7 @@ If you are using next-i18next in production, please consider [sponsoring the pac
|
|
|
14
13
|
|
|
15
14
|
While `next-i18next` uses [i18next](https://www.i18next.com/) and [react-i18next](https://github.com/i18next/react-i18next) under the hood, users of `next-i18next` simply need to include their translation content as JSON files and don't have to worry about much else.
|
|
16
15
|
|
|
17
|
-
A live demo is [available here](http://next-i18next.com/).
|
|
16
|
+
A live demo is [available here](http://next-i18next.com/). This demo app is the [simple example](./examples/simple/) - nothing more, nothing less.
|
|
18
17
|
|
|
19
18
|
## Setup
|
|
20
19
|
|
|
@@ -44,29 +43,24 @@ This structure can also be seen in the [simple example](./examples/simple).
|
|
|
44
43
|
|
|
45
44
|
If you want to structure your translations/namespaces in a custom way, you will need to pass modified `localePath` and `localeStructure` values into the initialisation config.
|
|
46
45
|
|
|
47
|
-
If translations are not found in `config.localePath` or `public/static/locales` an attempt will be made to find the locales in `static/locales`, if found a deprecation warning will be logged.
|
|
48
|
-
|
|
49
46
|
### 3. Project setup
|
|
50
47
|
|
|
51
48
|
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
49
|
|
|
53
50
|
```jsx
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const NextI18Next = require('next-i18next').default
|
|
52
|
+
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig
|
|
53
|
+
const path = require('path')
|
|
54
|
+
|
|
55
|
+
module.exports = new NextI18Next({
|
|
56
|
+
otherLanguages: ['de'],
|
|
57
|
+
localeSubpaths,
|
|
58
|
+
localePath: path.resolve('./public/static/locales')
|
|
59
59
|
})
|
|
60
|
-
|
|
61
|
-
export default NextI18NextInstance
|
|
62
|
-
|
|
63
|
-
/* Optionally, export class methods as named exports */
|
|
64
|
-
export const {
|
|
65
|
-
appWithTranslation,
|
|
66
|
-
withTranslation,
|
|
67
|
-
} = NextI18NextInstance
|
|
68
60
|
```
|
|
69
61
|
|
|
62
|
+
Note that `localePath` is required, and must be an absolute path.
|
|
63
|
+
|
|
70
64
|
[A full list of options can be seen here](#options).
|
|
71
65
|
|
|
72
66
|
It's recommended to export this `NextI18Next` instance from a single file in your project, where you can continually import it from to use the class methods as needed. You can see this approach in the [examples/simple/i18n.js](./examples/simple/i18n.js) file.
|
|
@@ -82,18 +76,16 @@ Note: You can pass `shallowRender: true` into config options to avoid triggering
|
|
|
82
76
|
That's it! Your app is ready to go. You can now use the `NextI18Next.withTranslation` HOC to make your components or pages translatable, based on namespaces:
|
|
83
77
|
|
|
84
78
|
```jsx
|
|
85
|
-
import React from 'react'
|
|
86
|
-
|
|
87
79
|
// This is our initialised `NextI18Next` instance
|
|
88
80
|
import { withTranslation } from '../i18n'
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
const Footer = ({ t }) => (
|
|
83
|
+
<footer>
|
|
84
|
+
<p>
|
|
85
|
+
{t('description')}
|
|
86
|
+
</p>
|
|
87
|
+
</footer>
|
|
88
|
+
)
|
|
97
89
|
|
|
98
90
|
export default withTranslation('footer')(Footer)
|
|
99
91
|
```
|
|
@@ -162,8 +154,6 @@ With this link, we would expect someone whose language is set to French to autom
|
|
|
162
154
|
To do that, we must import `Link` from your `NextI18Next` instance, **not next/router**:
|
|
163
155
|
|
|
164
156
|
```jsx
|
|
165
|
-
import React from 'react'
|
|
166
|
-
|
|
167
157
|
// This is our initialised `NextI18Next` instance
|
|
168
158
|
import { Link } from '../i18n'
|
|
169
159
|
|
|
@@ -177,8 +167,6 @@ const SomeLink = () => (
|
|
|
177
167
|
We can also navigate imperatively with locale subpaths by importing `Router` from your `NextI18Next` instance. The exported Router shares the same API as the native Next Router. The push, replace, and prefetch functions will automatically prepend locale subpaths.
|
|
178
168
|
|
|
179
169
|
```jsx
|
|
180
|
-
import React from 'react'
|
|
181
|
-
|
|
182
170
|
// This is our initialised `NextI18Next` instance
|
|
183
171
|
import { Router } from '../i18n'
|
|
184
172
|
|
|
@@ -191,25 +179,6 @@ const SomeButton = () => (
|
|
|
191
179
|
)
|
|
192
180
|
```
|
|
193
181
|
|
|
194
|
-
## Custom Routing
|
|
195
|
-
|
|
196
|
-
Custom routing can be achieved via the `app.render` method:
|
|
197
|
-
|
|
198
|
-
```jsx
|
|
199
|
-
/* First, use middleware */
|
|
200
|
-
server.use(nextI18NextMiddleware(nextI18next))
|
|
201
|
-
|
|
202
|
-
/* Second, declare custom routes */
|
|
203
|
-
server.get('/products/:id', (req, res) => {
|
|
204
|
-
const { query, params } = req
|
|
205
|
-
|
|
206
|
-
return app.render(req, res, '/product-page', { ...query, id: params.id })
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
/* Third, add catch-all GET for non-custom routes */
|
|
210
|
-
server.get('*', (req, res) => handle(req, res))
|
|
211
|
-
```
|
|
212
|
-
|
|
213
182
|
## Accessing the Current Language
|
|
214
183
|
|
|
215
184
|
In many cases, you'll need to know the currently active language. Most of the time, to accomplish this, you should use the `withTranslation` HOC, which will pass an `i18n` prop to the wrapped component and further asserts your component will get re-rendered on language change or changes to the translation catalog itself (loaded translations). More info can be found [here](https://react.i18next.com/latest/withtranslation-hoc).
|
|
@@ -235,7 +204,7 @@ MyPage.getInitialProps = async({ req }) => {
|
|
|
235
204
|
| `ignoreRoutes` | `['/_next/', '/static/', '/public/', '/api/']` |
|
|
236
205
|
| `otherLanguages` (required) | `[]` |
|
|
237
206
|
| `localeExtension` | `'json'` |
|
|
238
|
-
| `localePath` | `'public/static/locales'` |
|
|
207
|
+
| `localePath` (required) | `'/public/static/locales'` |
|
|
239
208
|
| `localeStructure` | `'{{lng}}/{{ns}}'` |
|
|
240
209
|
| `localeSubpaths` | `{}` |
|
|
241
210
|
| `serverLanguageDetection` | `true` |
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
|
-
[
|
|
15
|
+
[
|
|
16
|
+
"@babel/preset-react"
|
|
17
|
+
]
|
|
16
18
|
]
|
|
17
19
|
},
|
|
18
20
|
"cjs": {
|
|
@@ -23,19 +25,19 @@
|
|
|
23
25
|
{
|
|
24
26
|
"useBuiltIns": "usage",
|
|
25
27
|
"corejs": {
|
|
26
|
-
"version":
|
|
28
|
+
"version": 3
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
],
|
|
30
32
|
[
|
|
31
|
-
"next/babel",
|
|
33
|
+
"next/babel",
|
|
32
34
|
{
|
|
33
35
|
"transform-runtime": {
|
|
34
36
|
"corejs": false,
|
|
35
37
|
"helpers": true,
|
|
36
38
|
"regenerator": true,
|
|
37
39
|
"useESModules": false
|
|
38
|
-
}
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
]
|
|
41
43
|
],
|
|
@@ -61,7 +63,9 @@
|
|
|
61
63
|
"modules": "commonjs"
|
|
62
64
|
}
|
|
63
65
|
],
|
|
64
|
-
[
|
|
66
|
+
[
|
|
67
|
+
"@babel/preset-react"
|
|
68
|
+
]
|
|
65
69
|
],
|
|
66
70
|
"plugins": [
|
|
67
71
|
"@babel/proposal-class-properties",
|
|
@@ -72,6 +76,6 @@
|
|
|
72
76
|
}
|
|
73
77
|
]
|
|
74
78
|
]
|
|
75
|
-
}
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
require("core-js/modules/
|
|
5
|
+
require("core-js/modules/es.object.assign");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
@@ -25,8 +25,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
25
25
|
|
|
26
26
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
27
|
|
|
28
|
-
require("core-js/modules/es6.object.assign");
|
|
29
|
-
|
|
30
28
|
var _react = _interopRequireDefault(require("react"));
|
|
31
29
|
|
|
32
30
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -67,9 +65,7 @@ var removeWithTranslationProps = function removeWithTranslationProps(props) {
|
|
|
67
65
|
return strippedProps;
|
|
68
66
|
};
|
|
69
67
|
|
|
70
|
-
var Link =
|
|
71
|
-
/*#__PURE__*/
|
|
72
|
-
function (_React$Component) {
|
|
68
|
+
var Link = /*#__PURE__*/function (_React$Component) {
|
|
73
69
|
(0, _inherits2["default"])(Link, _React$Component);
|
|
74
70
|
|
|
75
71
|
function Link() {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
require("core-js/modules/es6.object.define-property");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -27,9 +25,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
27
25
|
|
|
28
26
|
var _reactI18next = require("react-i18next");
|
|
29
27
|
|
|
30
|
-
var NextStaticProvider =
|
|
31
|
-
/*#__PURE__*/
|
|
32
|
-
function (_React$Component) {
|
|
28
|
+
var NextStaticProvider = /*#__PURE__*/function (_React$Component) {
|
|
33
29
|
(0, _inherits2["default"])(NextStaticProvider, _React$Component);
|
|
34
30
|
|
|
35
31
|
function NextStaticProvider() {
|
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
require("core-js/modules/
|
|
5
|
+
require("core-js/modules/es.array.concat");
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.createConfig = void 0;
|
|
7
|
+
require("core-js/modules/es.array.filter");
|
|
11
8
|
|
|
12
|
-
require("core-js/modules/
|
|
9
|
+
require("core-js/modules/es.array.for-each");
|
|
13
10
|
|
|
14
|
-
require("core-js/modules/
|
|
11
|
+
require("core-js/modules/es.array.index-of");
|
|
15
12
|
|
|
16
|
-
require("core-js/modules/
|
|
13
|
+
require("core-js/modules/es.array.join");
|
|
17
14
|
|
|
18
|
-
require("core-js/modules/
|
|
15
|
+
require("core-js/modules/es.array.map");
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
require("core-js/modules/es.regexp.exec");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.string.replace");
|
|
21
20
|
|
|
22
|
-
require("core-js/modules/
|
|
21
|
+
require("core-js/modules/es.string.starts-with");
|
|
22
|
+
|
|
23
|
+
Object.defineProperty(exports, "__esModule", {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
exports.createConfig = void 0;
|
|
23
27
|
|
|
24
|
-
require("
|
|
28
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
|
|
25
29
|
|
|
26
30
|
var _defaultConfig = require("./default-config");
|
|
27
31
|
|
|
@@ -72,7 +76,7 @@ var createConfig = function createConfig(userConfig) {
|
|
|
72
76
|
|
|
73
77
|
if (typeof combinedConfig.defaultNS === 'string') {
|
|
74
78
|
var defaultFile = "/".concat(defaultLanguage, "/").concat(combinedConfig.defaultNS, ".").concat(localeExtension);
|
|
75
|
-
var defaultNSPath = path.join(
|
|
79
|
+
var defaultNSPath = path.join(localePath, defaultFile);
|
|
76
80
|
var defaultNSExists = fs.existsSync(defaultNSPath);
|
|
77
81
|
|
|
78
82
|
if (!defaultNSExists) {
|
|
@@ -80,7 +84,7 @@ var createConfig = function createConfig(userConfig) {
|
|
|
80
84
|
If defaultNS doesn't exist, try to fall back to the deprecated static folder
|
|
81
85
|
https://github.com/isaachinman/next-i18next/issues/523
|
|
82
86
|
*/
|
|
83
|
-
var staticDirPath = path.
|
|
87
|
+
var staticDirPath = path.resolve(process.cwd(), STATIC_LOCALE_PATH, defaultFile);
|
|
84
88
|
var staticDirExists = fs.existsSync(staticDirPath);
|
|
85
89
|
|
|
86
90
|
if (staticDirExists) {
|
|
@@ -97,13 +101,13 @@ var createConfig = function createConfig(userConfig) {
|
|
|
97
101
|
|
|
98
102
|
|
|
99
103
|
combinedConfig.backend = {
|
|
100
|
-
loadPath: path.
|
|
101
|
-
addPath: path.
|
|
102
|
-
/*
|
|
103
|
-
Set server side preload (languages and namespaces)
|
|
104
|
-
*/
|
|
105
|
-
|
|
104
|
+
loadPath: path.resolve(process.cwd(), "".concat(serverLocalePath, "/").concat(localeStructure, ".").concat(localeExtension)),
|
|
105
|
+
addPath: path.resolve(process.cwd(), "".concat(serverLocalePath, "/").concat(localeStructure, ".missing.").concat(localeExtension))
|
|
106
106
|
};
|
|
107
|
+
/*
|
|
108
|
+
Set server side preload (languages and namespaces)
|
|
109
|
+
*/
|
|
110
|
+
|
|
107
111
|
combinedConfig.preload = allLanguages;
|
|
108
112
|
|
|
109
113
|
if (!combinedConfig.ns) {
|
|
@@ -113,7 +117,7 @@ var createConfig = function createConfig(userConfig) {
|
|
|
113
117
|
});
|
|
114
118
|
};
|
|
115
119
|
|
|
116
|
-
combinedConfig.ns = getAllNamespaces(path.
|
|
120
|
+
combinedConfig.ns = getAllNamespaces(path.resolve(process.cwd(), "".concat(serverLocalePath, "/").concat(defaultLanguage)));
|
|
117
121
|
}
|
|
118
122
|
} else {
|
|
119
123
|
var clientLocalePath = localePath;
|
|
@@ -121,8 +125,8 @@ var createConfig = function createConfig(userConfig) {
|
|
|
121
125
|
Remove public prefix from client site config
|
|
122
126
|
*/
|
|
123
127
|
|
|
124
|
-
if (localePath.startsWith('public/')) {
|
|
125
|
-
clientLocalePath = localePath.replace(
|
|
128
|
+
if (localePath.startsWith('/public/')) {
|
|
129
|
+
clientLocalePath = localePath.replace(/^\/public/, '');
|
|
126
130
|
}
|
|
127
131
|
/*
|
|
128
132
|
Set client side backend
|
|
@@ -130,8 +134,8 @@ var createConfig = function createConfig(userConfig) {
|
|
|
130
134
|
|
|
131
135
|
|
|
132
136
|
combinedConfig.backend = {
|
|
133
|
-
loadPath: "
|
|
134
|
-
addPath: "
|
|
137
|
+
loadPath: "".concat(clientLocalePath, "/").concat(localeStructure, ".").concat(localeExtension),
|
|
138
|
+
addPath: "".concat(clientLocalePath, "/").concat(localeStructure, ".missing.").concat(localeExtension)
|
|
135
139
|
};
|
|
136
140
|
combinedConfig.ns = [combinedConfig.defaultNS];
|
|
137
141
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es6.object.define-property");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -12,7 +10,7 @@ var _utils = require("../utils");
|
|
|
12
10
|
var DEFAULT_LANGUAGE = 'en';
|
|
13
11
|
var OTHER_LANGUAGES = [];
|
|
14
12
|
var DEFAULT_NAMESPACE = 'common';
|
|
15
|
-
var LOCALE_PATH = 'public/static/locales';
|
|
13
|
+
var LOCALE_PATH = '/public/static/locales';
|
|
16
14
|
var LOCALE_STRUCTURE = '{{lng}}/{{ns}}';
|
|
17
15
|
var LOCALE_EXTENSION = 'json';
|
|
18
16
|
var defaultConfig = {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.for-each");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/web.dom-collections.for-each");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports["default"] = void 0;
|
|
13
|
+
|
|
14
|
+
var _i18next = _interopRequireDefault(require("i18next"));
|
|
15
|
+
|
|
16
|
+
var _cjs = _interopRequireDefault(require("i18next-http-backend/cjs"));
|
|
17
|
+
|
|
18
|
+
var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
|
|
19
|
+
|
|
20
|
+
var _default = function _default(config) {
|
|
21
|
+
var initPromise;
|
|
22
|
+
|
|
23
|
+
if (!_i18next["default"].isInitialized) {
|
|
24
|
+
_i18next["default"].use(_cjs["default"]);
|
|
25
|
+
|
|
26
|
+
if (config.browserLanguageDetection) {
|
|
27
|
+
var browserDetectors = new _i18nextBrowserLanguagedetector["default"]();
|
|
28
|
+
config.customDetectors.forEach(function (detector) {
|
|
29
|
+
return browserDetectors.addDetector(detector);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_i18next["default"].use(browserDetectors);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
config.use.forEach(function (x) {
|
|
36
|
+
return _i18next["default"].use(x);
|
|
37
|
+
});
|
|
38
|
+
initPromise = _i18next["default"].init(config);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
i18n: _i18next["default"],
|
|
43
|
+
initPromise: initPromise
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.for-each");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/web.dom-collections.for-each");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports["default"] = void 0;
|
|
13
|
+
|
|
14
|
+
var _i18next = _interopRequireDefault(require("i18next"));
|
|
15
|
+
|
|
16
|
+
var _cjs = _interopRequireDefault(require("i18next-fs-backend/cjs"));
|
|
17
|
+
|
|
18
|
+
var _cjs2 = _interopRequireDefault(require("i18next-http-middleware/cjs"));
|
|
19
|
+
|
|
20
|
+
var _default = function _default(config) {
|
|
21
|
+
var initPromise;
|
|
22
|
+
|
|
23
|
+
if (!_i18next["default"].isInitialized) {
|
|
24
|
+
_i18next["default"].use(_cjs["default"]);
|
|
25
|
+
|
|
26
|
+
if (config.serverLanguageDetection) {
|
|
27
|
+
var serverDetectors = new _cjs2["default"].LanguageDetector();
|
|
28
|
+
config.customDetectors.forEach(function (detector) {
|
|
29
|
+
return serverDetectors.addDetector(detector);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_i18next["default"].use(serverDetectors);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
config.use.forEach(function (x) {
|
|
36
|
+
return _i18next["default"].use(x);
|
|
37
|
+
});
|
|
38
|
+
initPromise = _i18next["default"].init(config);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
i18n: _i18next["default"],
|
|
43
|
+
initPromise: initPromise
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports["default"] = _default;
|