next-i18next 10.0.0 → 10.3.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 CHANGED
@@ -254,12 +254,38 @@ const Component = () => {
254
254
  }
255
255
  ```
256
256
 
257
+ #### Custom interpolation prefix/suffix
258
+
259
+ By default, i18next uses `{{` as prefix and `}}` as suffix for [interpolation](https://www.i18next.com/translation-function/interpolation).
260
+ If you want/need to override these interpolation settings, you **must** also specify an alternative `localeStructure` setting that matches your custom prefix and suffix.
261
+
262
+ For example, if you want to use `{` and `}` the config would look like this:
263
+
264
+ ```js
265
+ {
266
+ i18n: {
267
+ defaultLocale: 'en',
268
+ locales: ['en', 'nl'],
269
+ },
270
+ interpolation: {
271
+ prefix: '{',
272
+ suffix: '}',
273
+ },
274
+ localeStructure: '{lng}/{ns}',
275
+ }
276
+ ```
277
+
257
278
  ## Migration to v8
258
279
 
259
280
  To migrate from previous versions to the version 8, check out the [v8-migration guide](https://github.com/isaachinman/next-i18next/tree/master/docs/v8-migration.md)
260
281
 
261
282
  ## Notes
262
283
 
284
+ ### Vercel and Netlify
285
+
286
+ Some serverless PaaS may not be able to locate the path of your translations and require additional configuration. If you have filesystem issues using `serverSideTranslations`, set `config.localePath` to use `path.resolve`. An example can be [found here](https://github.com/isaachinman/next-i18next/issues/1552#issuecomment-981156476).
287
+
288
+
263
289
  ### Docker
264
290
 
265
291
  For Docker deployment, note that if you use the `Dockerfile` from [Next.js docs](https://nextjs.org/docs/deployment#docker-image) do not forget to copy `next.config.js` and `next-i18next.config.js` into the Docker image.
@@ -75,9 +75,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
75
75
 
76
76
  var __jsx = _react["default"].createElement;
77
77
 
78
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
78
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
79
79
 
80
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
80
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
81
81
 
82
82
  var globalI18n = null;
83
83
  exports.globalI18n = globalI18n;
@@ -86,9 +86,11 @@ var appWithTranslation = function appWithTranslation(WrappedComponent) {
86
86
  var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
87
87
 
88
88
  var AppWithTranslation = function AppWithTranslation(props) {
89
+ var _nextI18Next$initialL;
90
+
89
91
  var _ref = props.pageProps,
90
92
  _nextI18Next = _ref._nextI18Next;
91
- var locale = null; // Memoize the instance and only re-initialize when either:
93
+ var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : null; // Memoize the instance and only re-initialize when either:
92
94
  // 1. The route changes (non-shallowly)
93
95
  // 2. Router locale changes
94
96
 
@@ -97,9 +99,7 @@ var appWithTranslation = function appWithTranslation(WrappedComponent) {
97
99
 
98
100
  if (!_nextI18Next) return null;
99
101
  var userConfig = _nextI18Next.userConfig;
100
- var initialI18nStore = _nextI18Next.initialI18nStore,
101
- initialLocale = _nextI18Next.initialLocale;
102
- locale = initialLocale;
102
+ var initialI18nStore = _nextI18Next.initialI18nStore;
103
103
 
104
104
  if (userConfig === null && configOverride === null) {
105
105
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -75,15 +75,18 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
75
75
 
76
76
  var _defaultConfig = require("./defaultConfig");
77
77
 
78
+ var _excluded = ["i18n"],
79
+ _excluded2 = ["i18n"];
80
+
78
81
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
79
82
 
80
83
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
81
84
 
82
85
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
83
86
 
84
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
87
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
85
88
 
86
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
89
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
87
90
 
88
91
  var deepMergeObjects = ['backend', 'detection'];
89
92
 
@@ -98,9 +101,9 @@ var createConfig = function createConfig(userConfig) {
98
101
 
99
102
 
100
103
  var userI18n = userConfig.i18n,
101
- userConfigStripped = (0, _objectWithoutProperties2["default"])(userConfig, ["i18n"]);
104
+ userConfigStripped = (0, _objectWithoutProperties2["default"])(userConfig, _excluded);
102
105
  var defaultI18n = _defaultConfig.defaultConfig.i18n,
103
- defaultConfigStripped = (0, _objectWithoutProperties2["default"])(_defaultConfig.defaultConfig, ["i18n"]);
106
+ defaultConfigStripped = (0, _objectWithoutProperties2["default"])(_defaultConfig.defaultConfig, _excluded2);
104
107
 
105
108
  var combinedConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultConfigStripped), userConfigStripped), defaultI18n), userI18n);
106
109
 
@@ -24,6 +24,9 @@ var defaultConfig = {
24
24
  return process.browser && typeof window !== 'undefined';
25
25
  },
26
26
 
27
+ interpolation: {
28
+ escapeValue: false
29
+ },
27
30
  load: 'currentOnly',
28
31
  localeExtension: LOCALE_EXTENSION,
29
32
  localePath: LOCALE_PATH,
@@ -37,9 +37,9 @@ var _i18next = _interopRequireDefault(require("i18next"));
37
37
 
38
38
  var _i18nextFsBackend = _interopRequireDefault(require("i18next-fs-backend"));
39
39
 
40
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
41
 
42
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
43
 
44
44
  var globalInstance;
45
45
 
@@ -17,6 +17,12 @@ Object.defineProperty(exports, "Trans", {
17
17
  return _reactI18next.Trans;
18
18
  }
19
19
  });
20
+ Object.defineProperty(exports, "Translation", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _reactI18next.Translation;
24
+ }
25
+ });
20
26
  Object.defineProperty(exports, "useTranslation", {
21
27
  enumerable: true,
22
28
  get: function get() {
@@ -85,9 +85,9 @@ var _createClient2 = _interopRequireDefault(require("./createClient"));
85
85
 
86
86
  var _appWithTranslation = require("./appWithTranslation");
87
87
 
88
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
88
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
89
89
 
90
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
90
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
91
91
 
92
92
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
93
93
 
@@ -41,6 +41,12 @@ Object.defineProperty(exports, "DefaultNamespace", {
41
41
  return _reactI18next.DefaultNamespace;
42
42
  }
43
43
  });
44
+ Object.defineProperty(exports, "Translation", {
45
+ enumerable: true,
46
+ get: function get() {
47
+ return _reactI18next.Translation;
48
+ }
49
+ });
44
50
  Object.defineProperty(exports, "appWithTranslation", {
45
51
  enumerable: true,
46
52
  get: function get() {
@@ -12,7 +12,7 @@ export const appWithTranslation = (WrappedComponent, configOverride = null) => {
12
12
  const {
13
13
  _nextI18Next
14
14
  } = props.pageProps;
15
- let locale = null; // Memoize the instance and only re-initialize when either:
15
+ const locale = (_nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) ?? null; // Memoize the instance and only re-initialize when either:
16
16
  // 1. The route changes (non-shallowly)
17
17
  // 2. Router locale changes
18
18
 
@@ -24,10 +24,8 @@ export const appWithTranslation = (WrappedComponent, configOverride = null) => {
24
24
  userConfig
25
25
  } = _nextI18Next;
26
26
  const {
27
- initialI18nStore,
28
- initialLocale
27
+ initialI18nStore
29
28
  } = _nextI18Next;
30
- locale = initialLocale;
31
29
 
32
30
  if (userConfig === null && configOverride === null) {
33
31
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -16,6 +16,9 @@ export const defaultConfig = {
16
16
  return process.browser && typeof window !== 'undefined';
17
17
  },
18
18
 
19
+ interpolation: {
20
+ escapeValue: false
21
+ },
19
22
  load: 'currentOnly',
20
23
  localeExtension: LOCALE_EXTENSION,
21
24
  localePath: LOCALE_PATH,
package/dist/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { I18nContext, Trans, useTranslation, withTranslation } from 'react-i18next';
1
+ export { I18nContext, Trans, Translation, useTranslation, withTranslation } from 'react-i18next';
2
2
  export { appWithTranslation, globalI18n as i18n } from './appWithTranslation';
package/dist/es/types.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /* tslint:disable no-explicit-any */
2
- import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace } from 'react-i18next';
2
+ import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next';
3
3
  import { appWithTranslation, i18n } from './';
4
- export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, withTranslation, Resources, DefaultNamespace };
4
+ export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace };
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  var __jsx = React.createElement;
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  import React, { useMemo } from 'react';
10
10
  import hoistNonReactStatics from 'hoist-non-react-statics';
@@ -17,9 +17,11 @@ export var appWithTranslation = function appWithTranslation(WrappedComponent) {
17
17
  var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
18
18
 
19
19
  var AppWithTranslation = function AppWithTranslation(props) {
20
+ var _nextI18Next$initialL;
21
+
20
22
  var _ref = props.pageProps,
21
23
  _nextI18Next = _ref._nextI18Next;
22
- var locale = null; // Memoize the instance and only re-initialize when either:
24
+ var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : null; // Memoize the instance and only re-initialize when either:
23
25
  // 1. The route changes (non-shallowly)
24
26
  // 2. Router locale changes
25
27
 
@@ -28,9 +30,7 @@ export var appWithTranslation = function appWithTranslation(WrappedComponent) {
28
30
 
29
31
  if (!_nextI18Next) return null;
30
32
  var userConfig = _nextI18Next.userConfig;
31
- var initialI18nStore = _nextI18Next.initialI18nStore,
32
- initialLocale = _nextI18Next.initialLocale;
33
- locale = initialLocale;
33
+ var initialI18nStore = _nextI18Next.initialI18nStore;
34
34
 
35
35
  if (userConfig === null && configOverride === null) {
36
36
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -2,6 +2,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["i18n"],
6
+ _excluded2 = ["i18n"];
5
7
 
6
8
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
7
9
 
@@ -9,9 +11,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
9
11
 
10
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11
13
 
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
15
 
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
17
 
16
18
  import { defaultConfig } from './defaultConfig';
17
19
  var deepMergeObjects = ['backend', 'detection'];
@@ -26,10 +28,10 @@ export var createConfig = function createConfig(userConfig) {
26
28
 
27
29
 
28
30
  var userI18n = userConfig.i18n,
29
- userConfigStripped = _objectWithoutProperties(userConfig, ["i18n"]);
31
+ userConfigStripped = _objectWithoutProperties(userConfig, _excluded);
30
32
 
31
33
  var defaultI18n = defaultConfig.i18n,
32
- defaultConfigStripped = _objectWithoutProperties(defaultConfig, ["i18n"]);
34
+ defaultConfigStripped = _objectWithoutProperties(defaultConfig, _excluded2);
33
35
 
34
36
  var combinedConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultConfigStripped), userConfigStripped), defaultI18n), userI18n);
35
37
 
@@ -16,6 +16,9 @@ export var defaultConfig = {
16
16
  return process.browser && typeof window !== 'undefined';
17
17
  },
18
18
 
19
+ interpolation: {
20
+ escapeValue: false
21
+ },
19
22
  load: 'currentOnly',
20
23
  localeExtension: LOCALE_EXTENSION,
21
24
  localePath: LOCALE_PATH,
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
7
  import i18n from 'i18next';
8
8
  import i18nextFSBackend from 'i18next-fs-backend';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { I18nContext, Trans, useTranslation, withTranslation } from 'react-i18next';
1
+ export { I18nContext, Trans, Translation, useTranslation, withTranslation } from 'react-i18next';
2
2
  export { appWithTranslation, globalI18n as i18n } from './appWithTranslation';
@@ -1,12 +1,12 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
5
4
  import _typeof from "@babel/runtime/helpers/typeof";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
 
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
 
11
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
12
12
 
package/dist/esm/types.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /* tslint:disable no-explicit-any */
2
- import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace } from 'react-i18next';
2
+ import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next';
3
3
  import { appWithTranslation, i18n } from './';
4
- export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, withTranslation, Resources, DefaultNamespace };
4
+ export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace };
@@ -6,6 +6,9 @@ export declare const defaultConfig: {
6
6
  locales: string[];
7
7
  };
8
8
  readonly initImmediate: boolean;
9
+ interpolation: {
10
+ escapeValue: boolean;
11
+ };
9
12
  load: string;
10
13
  localeExtension: string;
11
14
  localePath: string;
@@ -1,2 +1,2 @@
1
- export { I18nContext, Trans, useTranslation, withTranslation } from 'react-i18next';
1
+ export { I18nContext, Trans, Translation, useTranslation, withTranslation } from 'react-i18next';
2
2
  export { appWithTranslation, globalI18n as i18n } from './appWithTranslation';
@@ -1,4 +1,4 @@
1
- import { I18nContext, useTranslation, Trans, withTranslation, WithTranslation as ReactI18nextWithTranslation, Resources, DefaultNamespace } from 'react-i18next';
1
+ import { I18nContext, useTranslation, Trans, withTranslation, WithTranslation as ReactI18nextWithTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next';
2
2
  import { InitOptions, i18n as I18NextClient, TFunction as I18NextTFunction } from 'i18next';
3
3
  import { appWithTranslation, i18n } from './';
4
4
  declare type NextJsI18NConfig = {
@@ -40,4 +40,4 @@ export declare type SSRConfig = {
40
40
  userConfig: UserConfig | null;
41
41
  };
42
42
  };
43
- export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, withTranslation, Resources, DefaultNamespace, };
43
+ export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-i18next",
3
- "version": "10.0.0",
3
+ "version": "10.3.0",
4
4
  "repository": "git@github.com:isaachinman/next-i18next.git",
5
5
  "author": "Isaac Hinman <isaac@isaachinman.com>",
6
6
  "funding": {
@@ -86,17 +86,17 @@
86
86
  "babel-plugin-add-module-exports": "^1.0.0",
87
87
  "babel-plugin-transform-async-to-generator": "^6.24.1",
88
88
  "bundlesize": "^0.18.0",
89
- "cypress": "^6.5.0",
89
+ "cypress": "^9.1.1",
90
90
  "eslint": "^7.17.0",
91
91
  "eslint-plugin-cypress": "^2.11.2",
92
92
  "eslint-plugin-import": "^2.22.1",
93
93
  "eslint-plugin-jest": "^24.1.5",
94
94
  "eslint-plugin-prefer-arrow": "^1.2.3",
95
95
  "eslint-plugin-react": "^7.22.0",
96
- "eslint-plugin-typescript-sort-keys": "^1.5.0",
96
+ "eslint-plugin-typescript-sort-keys": "^2.1.0",
97
97
  "husky": "^3.0.0",
98
98
  "jest": "^26.6.3",
99
- "next": "^10.0.4",
99
+ "next": "^11.1.3",
100
100
  "react": "^17.0.1",
101
101
  "react-dom": "^17.0.1",
102
102
  "start-server-and-test": "^1.12.0",