next-i18next
Advanced tools
Comparing version 12.1.0 to 13.0.0
"use strict"; | ||
require("core-js/modules/es.object.keys.js"); | ||
require("core-js/modules/es.symbol.js"); | ||
require("core-js/modules/es.array.filter.js"); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptor.js"); | ||
require("core-js/modules/es.array.for-each.js"); | ||
require("core-js/modules/web.dom-collections.for-each.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptors.js"); | ||
require("core-js/modules/es.object.define-properties.js"); | ||
require("core-js/modules/es.object.define-property.js"); | ||
require("core-js/modules/es.array.iterator.js"); | ||
require("core-js/modules/es.string.iterator.js"); | ||
require("core-js/modules/es.weak-map.js"); | ||
require("core-js/modules/web.dom-collections.iterator.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -57,69 +41,43 @@ value: true | ||
}); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
var _reactI18next = require("react-i18next"); | ||
var _createConfig = require("./config/createConfig"); | ||
var _createClient = _interopRequireDefault(require("./createClient")); | ||
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); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var __jsx = _react["default"].createElement; | ||
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; } | ||
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; } | ||
var globalI18n = null; | ||
exports.globalI18n = globalI18n; | ||
var appWithTranslation = function appWithTranslation(WrappedComponent) { | ||
var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var AppWithTranslation = function AppWithTranslation(props) { | ||
var _nextI18Next$initialL, _props$router; | ||
var _nextI18Next = props.pageProps._nextI18Next; | ||
var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : props === null || props === void 0 ? void 0 : (_props$router = props.router) === null || _props$router === void 0 ? void 0 : _props$router.locale; | ||
var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns; | ||
var _ref = props.pageProps, | ||
_nextI18Next = _ref._nextI18Next; | ||
var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : props === null || props === void 0 ? void 0 : (_props$router = props.router) === null || _props$router === void 0 ? void 0 : _props$router.locale; | ||
var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns; // Memoize the instance and only re-initialize when either: | ||
// Memoize the instance and only re-initialize when either: | ||
// 1. The route changes (non-shallowly) | ||
// 2. Router locale changes | ||
// 3. UserConfig override changes | ||
var i18n = (0, _react.useMemo)(function () { | ||
var _userConfig, _userConfig2, _userConfig2$i18n; | ||
var _userConfig$i18n; | ||
if (!_nextI18Next && !configOverride) return null; | ||
var userConfig = configOverride !== null && configOverride !== void 0 ? configOverride : _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.userConfig; | ||
if (!userConfig && configOverride === null) { | ||
if (!userConfig) { | ||
throw new Error('appWithTranslation was called without a next-i18next config'); | ||
} | ||
if (configOverride !== null) { | ||
userConfig = configOverride; | ||
} | ||
if (!((_userConfig = userConfig) !== null && _userConfig !== void 0 && _userConfig.i18n)) { | ||
if (!(userConfig !== null && userConfig !== void 0 && userConfig.i18n)) { | ||
throw new Error('appWithTranslation was called without config.i18n'); | ||
} | ||
if (!((_userConfig2 = userConfig) !== null && _userConfig2 !== void 0 && (_userConfig2$i18n = _userConfig2.i18n) !== null && _userConfig2$i18n !== void 0 && _userConfig2$i18n.defaultLocale)) { | ||
if (!(userConfig !== null && userConfig !== void 0 && (_userConfig$i18n = userConfig.i18n) !== null && _userConfig$i18n !== void 0 && _userConfig$i18n.defaultLocale)) { | ||
throw new Error('config.i18n does not include a defaultLocale property'); | ||
} | ||
var _ref2 = _nextI18Next || {}, | ||
initialI18nStore = _ref2.initialI18nStore; | ||
var _ref = _nextI18Next || {}, | ||
initialI18nStore = _ref.initialI18nStore; | ||
var resources = configOverride !== null && configOverride !== void 0 && configOverride.resources ? configOverride.resources : initialI18nStore; | ||
@@ -143,6 +101,4 @@ if (!locale) locale = userConfig.i18n.defaultLocale; | ||
}; | ||
return (0, _hoistNonReactStatics["default"])(AppWithTranslation, WrappedComponent); | ||
}; | ||
exports.appWithTranslation = appWithTranslation; |
"use strict"; | ||
require("core-js/modules/es.object.keys.js"); | ||
require("core-js/modules/es.symbol.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptor.js"); | ||
require("core-js/modules/web.dom-collections.for-each.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptors.js"); | ||
require("core-js/modules/es.object.define-properties.js"); | ||
require("core-js/modules/es.object.define-property.js"); | ||
require("core-js/modules/es.array.slice.js"); | ||
require("core-js/modules/es.function.name.js"); | ||
require("core-js/modules/es.array.from.js"); | ||
require("core-js/modules/es.string.iterator.js"); | ||
require("core-js/modules/es.symbol.description.js"); | ||
require("core-js/modules/es.symbol.iterator.js"); | ||
require("core-js/modules/es.array.iterator.js"); | ||
require("core-js/modules/web.dom-collections.iterator.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -39,88 +23,56 @@ value: true | ||
exports.createConfig = void 0; | ||
require("core-js/modules/es.array.filter.js"); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/es.regexp.exec.js"); | ||
require("core-js/modules/es.string.split.js"); | ||
require("core-js/modules/es.array.reduce.js"); | ||
require("core-js/modules/es.array.includes.js"); | ||
require("core-js/modules/es.string.includes.js"); | ||
require("core-js/modules/es.array.is-array.js"); | ||
require("core-js/modules/es.object.entries.js"); | ||
require("core-js/modules/es.array.concat.js"); | ||
require("core-js/modules/es.array.some.js"); | ||
require("core-js/modules/es.string.replace.js"); | ||
require("core-js/modules/es.array.join.js"); | ||
require("core-js/modules/es.array.map.js"); | ||
require("core-js/modules/es.array.for-each.js"); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _defaultConfig = require("./defaultConfig"); | ||
var _utils = require("../utils"); | ||
var _excluded = ["i18n"], | ||
_excluded2 = ["i18n"]; | ||
_excluded2 = ["i18n"]; | ||
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; } } }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
var deepMergeObjects = ['backend', 'detection']; | ||
var createConfig = function createConfig(userConfig) { | ||
var _userConfig$use; | ||
if (typeof (userConfig === null || userConfig === void 0 ? void 0 : userConfig.lng) !== 'string') { | ||
throw new Error('config.lng was not passed into createConfig'); | ||
} // | ||
} | ||
// | ||
// Initial merge of default and user-provided config | ||
// | ||
var userI18n = userConfig.i18n, | ||
userConfigStripped = (0, _objectWithoutProperties2["default"])(userConfig, _excluded); | ||
userConfigStripped = (0, _objectWithoutProperties2["default"])(userConfig, _excluded); | ||
var defaultI18n = _defaultConfig.defaultConfig.i18n, | ||
defaultConfigStripped = (0, _objectWithoutProperties2["default"])(_defaultConfig.defaultConfig, _excluded2); | ||
defaultConfigStripped = (0, _objectWithoutProperties2["default"])(_defaultConfig.defaultConfig, _excluded2); | ||
var combinedConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultConfigStripped), userConfigStripped), defaultI18n), userI18n); | ||
var defaultNS = combinedConfig.defaultNS, | ||
lng = combinedConfig.lng, | ||
localeExtension = combinedConfig.localeExtension, | ||
localePath = combinedConfig.localePath, | ||
localeStructure = combinedConfig.localeStructure, | ||
nonExplicitSupportedLngs = combinedConfig.nonExplicitSupportedLngs; | ||
lng = combinedConfig.lng, | ||
localeExtension = combinedConfig.localeExtension, | ||
localePath = combinedConfig.localePath, | ||
localeStructure = combinedConfig.localeStructure, | ||
nonExplicitSupportedLngs = combinedConfig.nonExplicitSupportedLngs; | ||
var locales = combinedConfig.locales.filter(function (l) { | ||
return l !== 'default'; | ||
}); | ||
/** | ||
@@ -130,29 +82,21 @@ * Skips translation file resolution while in cimode | ||
*/ | ||
if (lng === 'cimode') { | ||
return combinedConfig; | ||
} | ||
if (typeof combinedConfig.fallbackLng === 'undefined') { | ||
combinedConfig.fallbackLng = combinedConfig.defaultLocale; | ||
if (combinedConfig.fallbackLng === 'default') { | ||
var _locales = (0, _slicedToArray2["default"])(locales, 1); | ||
combinedConfig.fallbackLng = _locales[0]; | ||
} | ||
} | ||
var fallbackLng = combinedConfig.fallbackLng; | ||
if (nonExplicitSupportedLngs) { | ||
var createFallbackObject = function createFallbackObject(acc, l) { | ||
var _l$split = l.split('-'), | ||
_l$split2 = (0, _slicedToArray2["default"])(_l$split, 1), | ||
locale = _l$split2[0]; | ||
_l$split2 = (0, _slicedToArray2["default"])(_l$split, 1), | ||
locale = _l$split2[0]; | ||
acc[l] = [locale]; | ||
return acc; | ||
}; | ||
if (typeof fallbackLng === 'string') { | ||
@@ -173,5 +117,4 @@ combinedConfig.fallbackLng = combinedConfig.locales.filter(function (l) { | ||
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), | ||
l = _ref2[0], | ||
f = _ref2[1]; | ||
l = _ref2[0], | ||
f = _ref2[1]; | ||
acc[l] = l.includes('-') ? (0, _utils.unique)([l.split('-')[0]].concat((0, _toConsumableArray2["default"])(f))) : f; | ||
@@ -184,23 +127,18 @@ return acc; | ||
} | ||
var hasCustomBackend = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$use = userConfig.use) === null || _userConfig$use === void 0 ? void 0 : _userConfig$use.some(function (b) { | ||
return b.type === 'backend'; | ||
}); | ||
if (!process.browser && typeof window === 'undefined') { | ||
combinedConfig.preload = locales; | ||
if (!hasCustomBackend) { | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var path = require('path'); // | ||
// | ||
// Validate defaultNS | ||
// https://github.com/i18next/next-i18next/issues/358 | ||
// | ||
if (typeof defaultNS === 'string' && typeof lng !== 'undefined') { | ||
if (typeof localePath === 'string') { | ||
var _userConfig$interpola, _userConfig$interpola2, _userConfig$interpola3, _userConfig$interpola4; | ||
var prefix = (_userConfig$interpola = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$interpola2 = userConfig.interpolation) === null || _userConfig$interpola2 === void 0 ? void 0 : _userConfig$interpola2.prefix) !== null && _userConfig$interpola !== void 0 ? _userConfig$interpola : '{{'; | ||
@@ -218,3 +156,2 @@ var suffix = (_userConfig$interpola3 = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$interpola4 = userConfig.interpolation) === null || _userConfig$interpola4 === void 0 ? void 0 : _userConfig$interpola4.suffix) !== null && _userConfig$interpola3 !== void 0 ? _userConfig$interpola3 : '}}'; | ||
}); | ||
if (!defaultNSExists && !defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -225,7 +162,4 @@ throw new Error("Default namespace not found at ".concat(defaultNSPath)); | ||
var _defaultNSPath = localePath(lng, defaultNS, false); | ||
var _defaultNSExists = fs.existsSync(_defaultNSPath); | ||
var _fallback = (0, _utils.getFallbackForLng)(lng, combinedConfig.fallbackLng); | ||
var _defaultFallbackNSExists = _fallback.some(function (f) { | ||
@@ -235,3 +169,2 @@ var defaultNSPath = localePath(f, defaultNS, false); | ||
}); | ||
if (!_defaultNSExists && !_defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -241,7 +174,7 @@ throw new Error("Default namespace not found at ".concat(_defaultNSPath)); | ||
} | ||
} // | ||
} | ||
// | ||
// Set server side backend | ||
// | ||
if (typeof localePath === 'string') { | ||
@@ -263,7 +196,7 @@ combinedConfig.backend = { | ||
throw new Error("Unsupported localePath type: ".concat((0, _typeof2["default"])(localePath))); | ||
} // | ||
} | ||
// | ||
// Set server side preload (namespaces) | ||
// | ||
if (!combinedConfig.ns && typeof lng !== 'undefined') { | ||
@@ -273,3 +206,2 @@ if (typeof localePath === 'function') { | ||
} | ||
var getNamespaces = function getNamespaces(locales) { | ||
@@ -281,3 +213,2 @@ var getLocaleNamespaces = function getLocaleNamespaces(p) { | ||
var joinedP = path.join(p, file); | ||
if (fs.statSync(joinedP).isDirectory()) { | ||
@@ -290,3 +221,2 @@ var subRet = getLocaleNamespaces(joinedP).map(function (n) { | ||
} | ||
ret.push(file.replace(".".concat(localeExtension), '')); | ||
@@ -296,3 +226,2 @@ }); | ||
}; | ||
var namespacesByLocale = locales.map(function (locale) { | ||
@@ -302,6 +231,4 @@ return getLocaleNamespaces(path.resolve(process.cwd(), "".concat(localePath, "/").concat(locale))); | ||
var allNamespaces = []; | ||
var _iterator = _createForOfIteratorHelper(namespacesByLocale), | ||
_step; | ||
_step; | ||
try { | ||
@@ -317,6 +244,4 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
} | ||
return (0, _utils.unique)(allNamespaces); | ||
}; | ||
combinedConfig.ns = getNamespaces((0, _utils.unique)([lng].concat((0, _toConsumableArray2["default"])((0, _utils.getFallbackForLng)(lng, combinedConfig.fallbackLng))))); | ||
@@ -346,11 +271,10 @@ } | ||
} | ||
if (typeof combinedConfig.ns !== 'string' && !Array.isArray(combinedConfig.ns)) { | ||
combinedConfig.ns = [defaultNS]; | ||
} | ||
} // | ||
} | ||
// | ||
// Deep merge with overwrite - goes last | ||
// | ||
deepMergeObjects.forEach(function (obj) { | ||
@@ -363,3 +287,2 @@ if (userConfig[obj]) { | ||
}; | ||
exports.createConfig = createConfig; |
"use strict"; | ||
require("core-js/modules/es.object.define-property.js"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -22,7 +21,5 @@ value: true | ||
}, | ||
get initImmediate() { | ||
return process.browser && typeof window !== 'undefined'; | ||
}, | ||
interpolation: { | ||
@@ -29,0 +26,0 @@ escapeValue: false |
"use strict"; | ||
require("core-js/modules/es.object.define-property.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,31 +9,19 @@ value: true | ||
exports["default"] = void 0; | ||
require("core-js/modules/es.array.for-each.js"); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/web.dom-collections.for-each.js"); | ||
require("core-js/modules/es.promise.js"); | ||
var _i18next = _interopRequireDefault(require("i18next")); | ||
var _default = function _default(config) { | ||
if (config.ns === undefined) config.ns = []; | ||
var instance = _i18next["default"].createInstance(config); | ||
var initPromise; | ||
if (!instance.isInitialized) { | ||
var _config$use; | ||
config === null || config === void 0 ? void 0 : (_config$use = config.use) === null || _config$use === void 0 ? void 0 : _config$use.forEach(function (x) { | ||
return instance.use(x); | ||
}); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -45,3 +31,2 @@ } else { | ||
} | ||
return { | ||
@@ -52,5 +37,4 @@ i18n: instance, | ||
}; | ||
exports["default"] = _default; | ||
module.exports = exports.default; | ||
module.exports.default = exports.default; |
"use strict"; | ||
require("core-js/modules/es.object.keys.js"); | ||
require("core-js/modules/es.symbol.js"); | ||
require("core-js/modules/es.array.filter.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptor.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptors.js"); | ||
require("core-js/modules/es.object.define-properties.js"); | ||
require("core-js/modules/es.object.define-property.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -23,29 +15,16 @@ value: true | ||
exports["default"] = void 0; | ||
require("core-js/modules/es.array.some.js"); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/es.array.for-each.js"); | ||
require("core-js/modules/web.dom-collections.for-each.js"); | ||
require("core-js/modules/es.promise.js"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _i18next = _interopRequireDefault(require("i18next")); | ||
var _i18nextFsBackend = _interopRequireDefault(require("i18next-fs-backend")); | ||
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; } | ||
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; } | ||
var globalInstance; | ||
var _default = function _default(config) { | ||
if (config.ns === undefined) config.ns = []; | ||
var instance; | ||
if (!globalInstance) { | ||
@@ -59,24 +38,17 @@ globalInstance = _i18next["default"].createInstance(config); | ||
} | ||
var initPromise; | ||
if (!instance.isInitialized) { | ||
var _config$use, _config$use2; | ||
var hasCustomBackend = config === null || config === void 0 ? void 0 : (_config$use = config.use) === null || _config$use === void 0 ? void 0 : _config$use.some(function (b) { | ||
return b.type === 'backend'; | ||
}); | ||
if (!hasCustomBackend) { | ||
instance.use(_i18nextFsBackend["default"]); | ||
} | ||
config === null || config === void 0 ? void 0 : (_config$use2 = config.use) === null || _config$use2 === void 0 ? void 0 : _config$use2.forEach(function (x) { | ||
return instance.use(x); | ||
}); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -86,3 +58,2 @@ } else { | ||
} | ||
return { | ||
@@ -93,5 +64,4 @@ i18n: instance, | ||
}; | ||
exports["default"] = _default; | ||
module.exports = exports.default; | ||
module.exports.default = exports.default; |
"use strict"; | ||
require("core-js/modules/es.object.define-property.js"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -50,5 +49,3 @@ value: true | ||
}); | ||
var _reactI18next = require("react-i18next"); | ||
var _appWithTranslation = require("./appWithTranslation"); |
"use strict"; | ||
require("core-js/modules/es.array.iterator.js"); | ||
require("core-js/modules/es.string.iterator.js"); | ||
require("core-js/modules/es.weak-map.js"); | ||
require("core-js/modules/web.dom-collections.iterator.js"); | ||
require("core-js/modules/es.object.define-property.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptor.js"); | ||
require("core-js/modules/es.symbol.js"); | ||
require("core-js/modules/es.array.filter.js"); | ||
require("core-js/modules/es.object.get-own-property-descriptors.js"); | ||
require("core-js/modules/es.object.define-properties.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -31,74 +19,46 @@ value: true | ||
exports.serverSideTranslations = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/es.promise.js"); | ||
require("core-js/modules/es.array.for-each.js"); | ||
require("core-js/modules/web.dom-collections.for-each.js"); | ||
require("core-js/modules/es.array.concat.js"); | ||
require("core-js/modules/es.array.is-array.js"); | ||
require("core-js/modules/es.array.map.js"); | ||
require("core-js/modules/es.regexp.exec.js"); | ||
require("core-js/modules/es.string.replace.js"); | ||
require("core-js/modules/es.array.flat.js"); | ||
require("core-js/modules/es.array.unscopables.flat.js"); | ||
require("core-js/modules/es.object.keys.js"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _createConfig = require("./config/createConfig"); | ||
var _createClient2 = _interopRequireDefault(require("./createClient")); | ||
var _node = _interopRequireDefault(require("./createClient/node")); | ||
var _appWithTranslation = require("./appWithTranslation"); | ||
var _utils = require("./utils"); | ||
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; } | ||
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; } | ||
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); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var DEFAULT_CONFIG_PATH = './next-i18next.config.js'; | ||
var serverSideTranslations = /*#__PURE__*/function () { | ||
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(initialLocale) { | ||
var namespacesRequired, | ||
configOverride, | ||
extraLocales, | ||
userConfig, | ||
config, | ||
localeExtension, | ||
localePath, | ||
fallbackLng, | ||
reloadOnPrerender, | ||
_createClient, | ||
i18n, | ||
initPromise, | ||
initialI18nStore, | ||
getLocaleNamespaces, | ||
namespacesByLocale, | ||
_args = arguments; | ||
configOverride, | ||
extraLocales, | ||
userConfig, | ||
config, | ||
localeExtension, | ||
localePath, | ||
fallbackLng, | ||
reloadOnPrerender, | ||
_createClient, | ||
i18n, | ||
initPromise, | ||
initialI18nStore, | ||
getLocaleNamespaces, | ||
namespacesByLocale, | ||
_args = arguments; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
@@ -111,3 +71,2 @@ while (1) { | ||
extraLocales = _args.length > 3 && _args[3] !== undefined ? _args[3] : false; | ||
if (!(typeof initialLocale !== 'string')) { | ||
@@ -117,8 +76,5 @@ _context.next = 5; | ||
} | ||
throw new Error('Initial locale argument was not passed into serverSideTranslations'); | ||
case 5: | ||
userConfig = configOverride; | ||
if (!(!userConfig && _fs["default"].existsSync(_path["default"].resolve(DEFAULT_CONFIG_PATH)))) { | ||
@@ -128,3 +84,2 @@ _context.next = 10; | ||
} | ||
_context.next = 9; | ||
@@ -134,6 +89,4 @@ return Promise.resolve("".concat(_path["default"].resolve(DEFAULT_CONFIG_PATH))).then(function (s) { | ||
}); | ||
case 9: | ||
userConfig = _context.sent; | ||
case 10: | ||
@@ -144,5 +97,3 @@ if (!(userConfig === null)) { | ||
} | ||
throw new Error('next-i18next was unable to find a user config'); | ||
case 12: | ||
@@ -153,3 +104,2 @@ config = (0, _createConfig.createConfig)(_objectSpread(_objectSpread({}, userConfig), {}, { | ||
localeExtension = config.localeExtension, localePath = config.localePath, fallbackLng = config.fallbackLng, reloadOnPrerender = config.reloadOnPrerender; | ||
if (!reloadOnPrerender) { | ||
@@ -159,8 +109,6 @@ _context.next = 17; | ||
} | ||
_context.next = 17; | ||
return _appWithTranslation.globalI18n === null || _appWithTranslation.globalI18n === void 0 ? void 0 : _appWithTranslation.globalI18n.reloadResources(); | ||
case 17: | ||
_createClient = (0, _createClient2["default"])(_objectSpread(_objectSpread({}, config), {}, { | ||
_createClient = (0, _node["default"])(_objectSpread(_objectSpread({}, config), {}, { | ||
lng: initialLocale | ||
@@ -170,3 +118,2 @@ })), i18n = _createClient.i18n, initPromise = _createClient.initPromise; | ||
return initPromise; | ||
case 20: | ||
@@ -177,3 +124,2 @@ initialI18nStore = (0, _defineProperty2["default"])({}, initialLocale, {}); | ||
}); | ||
if (Array.isArray(namespacesRequired)) { | ||
@@ -183,3 +129,2 @@ _context.next = 28; | ||
} | ||
if (!(typeof localePath === 'function')) { | ||
@@ -189,5 +134,3 @@ _context.next = 25; | ||
} | ||
throw new Error('Must provide namespacesRequired to serverSideTranslations when using a function as localePath'); | ||
case 25: | ||
@@ -199,3 +142,2 @@ getLocaleNamespaces = function getLocaleNamespaces(path) { | ||
}; | ||
namespacesByLocale = Object.keys(initialI18nStore).map(function (locale) { | ||
@@ -205,3 +147,2 @@ return getLocaleNamespaces(_path["default"].resolve(process.cwd(), "".concat(localePath, "/").concat(locale))); | ||
namespacesRequired = (0, _utils.unique)(namespacesByLocale); | ||
case 28: | ||
@@ -221,3 +162,2 @@ namespacesRequired.forEach(function (ns) { | ||
}); | ||
case 30: | ||
@@ -230,3 +170,2 @@ case "end": | ||
})); | ||
return function serverSideTranslations(_x) { | ||
@@ -236,3 +175,2 @@ return _ref.apply(this, arguments); | ||
}(); | ||
exports.serverSideTranslations = serverSideTranslations; |
"use strict"; | ||
require("core-js/modules/es.object.define-property.js"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -20,8 +19,2 @@ value: true | ||
}); | ||
Object.defineProperty(exports, "Resources", { | ||
enumerable: true, | ||
get: function get() { | ||
return _reactI18next.Resources; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Trans", { | ||
@@ -63,5 +56,3 @@ enumerable: true, | ||
}); | ||
var _reactI18next = require("react-i18next"); | ||
var _ = require("./"); |
"use strict"; | ||
require("core-js/modules/es.object.define-property.js"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,23 +9,12 @@ value: true | ||
exports.unique = exports.getFallbackForLng = void 0; | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
require("core-js/modules/es.array.is-array.js"); | ||
require("core-js/modules/es.array.concat.js"); | ||
require("core-js/modules/es.array.from.js"); | ||
require("core-js/modules/es.string.iterator.js"); | ||
require("core-js/modules/es.array.iterator.js"); | ||
require("core-js/modules/es.object.to-string.js"); | ||
require("core-js/modules/es.set.js"); | ||
require("core-js/modules/web.dom-collections.iterator.js"); | ||
var getFallbackForLng = function getFallbackForLng(lng, fallbackLng) { | ||
@@ -37,7 +24,5 @@ if (typeof fallbackLng === 'string') { | ||
} | ||
if (Array.isArray(fallbackLng)) { | ||
return fallbackLng; | ||
} | ||
if ((0, _typeof2["default"])(fallbackLng) === 'object') { | ||
@@ -48,16 +33,11 @@ var fallbackList = fallbackLng[lng]; | ||
} | ||
if (typeof fallbackLng === 'function') { | ||
return getFallbackForLng(lng, fallbackLng(lng)); | ||
} | ||
return []; | ||
}; | ||
exports.getFallbackForLng = getFallbackForLng; | ||
var unique = function unique(list) { | ||
return Array.from(new Set(list)); | ||
}; | ||
exports.unique = unique; |
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import React, { useMemo } from 'react'; | ||
@@ -16,27 +15,20 @@ import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
let locale = _nextI18Next?.initialLocale ?? props?.router?.locale; | ||
const ns = _nextI18Next?.ns; // Memoize the instance and only re-initialize when either: | ||
const ns = _nextI18Next?.ns; | ||
// Memoize the instance and only re-initialize when either: | ||
// 1. The route changes (non-shallowly) | ||
// 2. Router locale changes | ||
// 3. UserConfig override changes | ||
const i18n = useMemo(() => { | ||
if (!_nextI18Next && !configOverride) return null; | ||
let userConfig = configOverride ?? _nextI18Next?.userConfig; | ||
if (!userConfig && configOverride === null) { | ||
const userConfig = configOverride ?? _nextI18Next?.userConfig; | ||
if (!userConfig) { | ||
throw new Error('appWithTranslation was called without a next-i18next config'); | ||
} | ||
if (configOverride !== null) { | ||
userConfig = configOverride; | ||
} | ||
if (!userConfig?.i18n) { | ||
throw new Error('appWithTranslation was called without config.i18n'); | ||
} | ||
if (!userConfig?.i18n?.defaultLocale) { | ||
throw new Error('config.i18n does not include a defaultLocale property'); | ||
} | ||
const { | ||
@@ -47,3 +39,5 @@ initialI18nStore | ||
if (!locale) locale = userConfig.i18n.defaultLocale; | ||
const instance = createClient({ ...createConfig({ ...userConfig, | ||
const instance = createClient({ | ||
...createConfig({ | ||
...userConfig, | ||
lng: locale | ||
@@ -64,4 +58,3 @@ }), | ||
}; | ||
return hoistNonReactStatics(AppWithTranslation, WrappedComponent); | ||
}; |
@@ -7,7 +7,7 @@ import { defaultConfig } from './defaultConfig'; | ||
throw new Error('config.lng was not passed into createConfig'); | ||
} // | ||
} | ||
// | ||
// Initial merge of default and user-provided config | ||
// | ||
const { | ||
@@ -21,3 +21,4 @@ i18n: userI18n, | ||
} = defaultConfig; | ||
const combinedConfig = { ...defaultConfigStripped, | ||
const combinedConfig = { | ||
...defaultConfigStripped, | ||
...userConfigStripped, | ||
@@ -36,2 +37,3 @@ ...defaultI18n, | ||
const locales = combinedConfig.locales.filter(l => l !== 'default'); | ||
/** | ||
@@ -41,7 +43,5 @@ * Skips translation file resolution while in cimode | ||
*/ | ||
if (lng === 'cimode') { | ||
return combinedConfig; | ||
} | ||
if (typeof combinedConfig.fallbackLng === 'undefined') { | ||
@@ -51,7 +51,5 @@ combinedConfig.fallbackLng = combinedConfig.defaultLocale; | ||
} | ||
const { | ||
fallbackLng | ||
} = combinedConfig; | ||
if (nonExplicitSupportedLngs) { | ||
@@ -63,3 +61,2 @@ const createFallbackObject = (acc, l) => { | ||
}; | ||
if (typeof fallbackLng === 'string') { | ||
@@ -82,17 +79,13 @@ combinedConfig.fallbackLng = combinedConfig.locales.filter(l => l.includes('-')).reduce(createFallbackObject, { | ||
} | ||
const hasCustomBackend = userConfig?.use?.some(b => b.type === 'backend'); | ||
if (!process.browser && typeof window === 'undefined') { | ||
combinedConfig.preload = locales; | ||
if (!hasCustomBackend) { | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const path = require('path'); // | ||
// | ||
// Validate defaultNS | ||
// https://github.com/i18next/next-i18next/issues/358 | ||
// | ||
if (typeof defaultNS === 'string' && typeof lng !== 'undefined') { | ||
@@ -112,3 +105,2 @@ if (typeof localePath === 'string') { | ||
}); | ||
if (!defaultNSExists && !defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -125,3 +117,2 @@ throw new Error(`Default namespace not found at ${defaultNSPath}`); | ||
}); | ||
if (!defaultNSExists && !defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -131,7 +122,7 @@ throw new Error(`Default namespace not found at ${defaultNSPath}`); | ||
} | ||
} // | ||
} | ||
// | ||
// Set server side backend | ||
// | ||
if (typeof localePath === 'string') { | ||
@@ -149,7 +140,7 @@ combinedConfig.backend = { | ||
throw new Error(`Unsupported localePath type: ${typeof localePath}`); | ||
} // | ||
} | ||
// | ||
// Set server side preload (namespaces) | ||
// | ||
if (!combinedConfig.ns && typeof lng !== 'undefined') { | ||
@@ -159,3 +150,2 @@ if (typeof localePath === 'function') { | ||
} | ||
const getNamespaces = locales => { | ||
@@ -167,3 +157,2 @@ const getLocaleNamespaces = p => { | ||
const joinedP = path.join(p, file); | ||
if (fs.statSync(joinedP).isDirectory()) { | ||
@@ -174,3 +163,2 @@ const subRet = getLocaleNamespaces(joinedP).map(n => `${file}/${n}`); | ||
} | ||
ret.push(file.replace(`.${localeExtension}`, '')); | ||
@@ -180,13 +168,9 @@ }); | ||
}; | ||
const namespacesByLocale = locales.map(locale => getLocaleNamespaces(path.resolve(process.cwd(), `${localePath}/${locale}`))); | ||
const allNamespaces = []; | ||
for (const localNamespaces of namespacesByLocale) { | ||
allNamespaces.push(...localNamespaces); | ||
} | ||
return unique(allNamespaces); | ||
}; | ||
combinedConfig.ns = getNamespaces(unique([lng, ...getFallbackForLng(lng, combinedConfig.fallbackLng)])); | ||
@@ -212,14 +196,14 @@ } | ||
} | ||
if (typeof combinedConfig.ns !== 'string' && !Array.isArray(combinedConfig.ns)) { | ||
combinedConfig.ns = [defaultNS]; | ||
} | ||
} // | ||
} | ||
// | ||
// Deep merge with overwrite - goes last | ||
// | ||
deepMergeObjects.forEach(obj => { | ||
if (userConfig[obj]) { | ||
combinedConfig[obj] = { ...combinedConfig[obj], | ||
combinedConfig[obj] = { | ||
...combinedConfig[obj], | ||
...userConfig[obj] | ||
@@ -226,0 +210,0 @@ }; |
@@ -14,7 +14,5 @@ const DEFAULT_LOCALE = 'en'; | ||
}, | ||
get initImmediate() { | ||
return process.browser && typeof window !== 'undefined'; | ||
}, | ||
interpolation: { | ||
@@ -21,0 +19,0 @@ escapeValue: false |
@@ -6,10 +6,7 @@ import i18n from 'i18next'; | ||
let initPromise; | ||
if (!instance.isInitialized) { | ||
config?.use?.forEach(x => instance.use(x)); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -19,3 +16,2 @@ } else { | ||
} | ||
return { | ||
@@ -22,0 +18,0 @@ i18n: instance, |
@@ -7,3 +7,2 @@ import i18n from 'i18next'; | ||
let instance; | ||
if (!globalInstance) { | ||
@@ -13,22 +12,17 @@ globalInstance = i18n.createInstance(config); | ||
} else { | ||
instance = globalInstance.cloneInstance({ ...config, | ||
instance = globalInstance.cloneInstance({ | ||
...config, | ||
initImmediate: false | ||
}); | ||
} | ||
let initPromise; | ||
if (!instance.isInitialized) { | ||
const hasCustomBackend = config?.use?.some(b => b.type === 'backend'); | ||
if (!hasCustomBackend) { | ||
instance.use(i18nextFSBackend); | ||
} | ||
config?.use?.forEach(x => instance.use(x)); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -38,3 +32,2 @@ } else { | ||
} | ||
return { | ||
@@ -41,0 +34,0 @@ i18n: instance, |
import fs from 'fs'; | ||
import path from 'path'; | ||
import { createConfig } from './config/createConfig'; | ||
import createClient from './createClient'; | ||
import createClient from './createClient/node'; | ||
import { globalI18n } from './appWithTranslation'; | ||
@@ -12,14 +12,11 @@ import { getFallbackForLng, unique } from './utils'; | ||
} | ||
let userConfig = configOverride; | ||
if (!userConfig && fs.existsSync(path.resolve(DEFAULT_CONFIG_PATH))) { | ||
userConfig = await import(path.resolve(DEFAULT_CONFIG_PATH)); | ||
} | ||
if (userConfig === null) { | ||
throw new Error('next-i18next was unable to find a user config'); | ||
} | ||
const config = createConfig({ ...userConfig, | ||
const config = createConfig({ | ||
...userConfig, | ||
lng: initialLocale | ||
@@ -33,11 +30,10 @@ }); | ||
} = config; | ||
if (reloadOnPrerender) { | ||
await globalI18n?.reloadResources(); | ||
} | ||
const { | ||
i18n, | ||
initPromise | ||
} = createClient({ ...config, | ||
} = createClient({ | ||
...config, | ||
lng: initialLocale | ||
@@ -52,3 +48,2 @@ }); | ||
}); | ||
if (!Array.isArray(namespacesRequired)) { | ||
@@ -58,9 +53,6 @@ if (typeof localePath === 'function') { | ||
} | ||
const getLocaleNamespaces = path => fs.existsSync(path) ? fs.readdirSync(path).map(file => file.replace(`.${localeExtension}`, '')) : []; | ||
const namespacesByLocale = Object.keys(initialI18nStore).map(locale => getLocaleNamespaces(path.resolve(process.cwd(), `${localePath}/${locale}`))).flat(); | ||
namespacesRequired = unique(namespacesByLocale); | ||
} | ||
namespacesRequired.forEach(ns => { | ||
@@ -67,0 +59,0 @@ for (const locale in initialI18nStore) { |
/* tslint:disable no-explicit-any */ | ||
import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { I18nContext, useTranslation, Trans, withTranslation, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { appWithTranslation, i18n } from './'; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace }; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, DefaultNamespace }; |
@@ -5,7 +5,5 @@ export const getFallbackForLng = (lng, fallbackLng) => { | ||
} | ||
if (Array.isArray(fallbackLng)) { | ||
return fallbackLng; | ||
} | ||
if (typeof fallbackLng === 'object') { | ||
@@ -16,9 +14,7 @@ const fallbackList = fallbackLng[lng]; | ||
} | ||
if (typeof fallbackLng === 'function') { | ||
return getFallbackForLng(lng, fallbackLng(lng)); | ||
} | ||
return []; | ||
}; | ||
export const unique = list => Array.from(new Set(list)); |
import _extends from "@babel/runtime/helpers/extends"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
var __jsx = React.createElement; | ||
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; } | ||
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; } | ||
import React, { useMemo } from 'react'; | ||
@@ -18,39 +15,27 @@ import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var AppWithTranslation = function AppWithTranslation(props) { | ||
var _nextI18Next$initialL, _props$router; | ||
var _nextI18Next = props.pageProps._nextI18Next; | ||
var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : props === null || props === void 0 ? void 0 : (_props$router = props.router) === null || _props$router === void 0 ? void 0 : _props$router.locale; | ||
var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns; | ||
var _ref = props.pageProps, | ||
_nextI18Next = _ref._nextI18Next; | ||
var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : props === null || props === void 0 ? void 0 : (_props$router = props.router) === null || _props$router === void 0 ? void 0 : _props$router.locale; | ||
var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns; // Memoize the instance and only re-initialize when either: | ||
// Memoize the instance and only re-initialize when either: | ||
// 1. The route changes (non-shallowly) | ||
// 2. Router locale changes | ||
// 3. UserConfig override changes | ||
var i18n = useMemo(function () { | ||
var _userConfig, _userConfig2, _userConfig2$i18n; | ||
var _userConfig$i18n; | ||
if (!_nextI18Next && !configOverride) return null; | ||
var userConfig = configOverride !== null && configOverride !== void 0 ? configOverride : _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.userConfig; | ||
if (!userConfig && configOverride === null) { | ||
if (!userConfig) { | ||
throw new Error('appWithTranslation was called without a next-i18next config'); | ||
} | ||
if (configOverride !== null) { | ||
userConfig = configOverride; | ||
} | ||
if (!((_userConfig = userConfig) !== null && _userConfig !== void 0 && _userConfig.i18n)) { | ||
if (!(userConfig !== null && userConfig !== void 0 && userConfig.i18n)) { | ||
throw new Error('appWithTranslation was called without config.i18n'); | ||
} | ||
if (!((_userConfig2 = userConfig) !== null && _userConfig2 !== void 0 && (_userConfig2$i18n = _userConfig2.i18n) !== null && _userConfig2$i18n !== void 0 && _userConfig2$i18n.defaultLocale)) { | ||
if (!(userConfig !== null && userConfig !== void 0 && (_userConfig$i18n = userConfig.i18n) !== null && _userConfig$i18n !== void 0 && _userConfig$i18n.defaultLocale)) { | ||
throw new Error('config.i18n does not include a defaultLocale property'); | ||
} | ||
var _ref2 = _nextI18Next || {}, | ||
initialI18nStore = _ref2.initialI18nStore; | ||
var _ref = _nextI18Next || {}, | ||
initialI18nStore = _ref.initialI18nStore; | ||
var resources = configOverride !== null && configOverride !== void 0 && configOverride.resources ? configOverride.resources : initialI18nStore; | ||
@@ -74,4 +59,3 @@ if (!locale) locale = userConfig.i18n.defaultLocale; | ||
}; | ||
return hoistNonReactStatics(AppWithTranslation, WrappedComponent); | ||
}; |
@@ -7,14 +7,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
var _excluded = ["i18n"], | ||
_excluded2 = ["i18n"]; | ||
_excluded2 = ["i18n"]; | ||
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; } } }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
import { defaultConfig } from './defaultConfig'; | ||
@@ -25,27 +19,24 @@ import { getFallbackForLng, unique } from '../utils'; | ||
var _userConfig$use; | ||
if (typeof (userConfig === null || userConfig === void 0 ? void 0 : userConfig.lng) !== 'string') { | ||
throw new Error('config.lng was not passed into createConfig'); | ||
} // | ||
} | ||
// | ||
// Initial merge of default and user-provided config | ||
// | ||
var userI18n = userConfig.i18n, | ||
userConfigStripped = _objectWithoutProperties(userConfig, _excluded); | ||
userConfigStripped = _objectWithoutProperties(userConfig, _excluded); | ||
var defaultI18n = defaultConfig.i18n, | ||
defaultConfigStripped = _objectWithoutProperties(defaultConfig, _excluded2); | ||
defaultConfigStripped = _objectWithoutProperties(defaultConfig, _excluded2); | ||
var combinedConfig = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultConfigStripped), userConfigStripped), defaultI18n), userI18n); | ||
var defaultNS = combinedConfig.defaultNS, | ||
lng = combinedConfig.lng, | ||
localeExtension = combinedConfig.localeExtension, | ||
localePath = combinedConfig.localePath, | ||
localeStructure = combinedConfig.localeStructure, | ||
nonExplicitSupportedLngs = combinedConfig.nonExplicitSupportedLngs; | ||
lng = combinedConfig.lng, | ||
localeExtension = combinedConfig.localeExtension, | ||
localePath = combinedConfig.localePath, | ||
localeStructure = combinedConfig.localeStructure, | ||
nonExplicitSupportedLngs = combinedConfig.nonExplicitSupportedLngs; | ||
var locales = combinedConfig.locales.filter(function (l) { | ||
return l !== 'default'; | ||
}); | ||
/** | ||
@@ -55,29 +46,21 @@ * Skips translation file resolution while in cimode | ||
*/ | ||
if (lng === 'cimode') { | ||
return combinedConfig; | ||
} | ||
if (typeof combinedConfig.fallbackLng === 'undefined') { | ||
combinedConfig.fallbackLng = combinedConfig.defaultLocale; | ||
if (combinedConfig.fallbackLng === 'default') { | ||
var _locales = _slicedToArray(locales, 1); | ||
combinedConfig.fallbackLng = _locales[0]; | ||
} | ||
} | ||
var fallbackLng = combinedConfig.fallbackLng; | ||
if (nonExplicitSupportedLngs) { | ||
var createFallbackObject = function createFallbackObject(acc, l) { | ||
var _l$split = l.split('-'), | ||
_l$split2 = _slicedToArray(_l$split, 1), | ||
locale = _l$split2[0]; | ||
_l$split2 = _slicedToArray(_l$split, 1), | ||
locale = _l$split2[0]; | ||
acc[l] = [locale]; | ||
return acc; | ||
}; | ||
if (typeof fallbackLng === 'string') { | ||
@@ -98,5 +81,4 @@ combinedConfig.fallbackLng = combinedConfig.locales.filter(function (l) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
l = _ref2[0], | ||
f = _ref2[1]; | ||
l = _ref2[0], | ||
f = _ref2[1]; | ||
acc[l] = l.includes('-') ? unique([l.split('-')[0]].concat(_toConsumableArray(f))) : f; | ||
@@ -109,23 +91,18 @@ return acc; | ||
} | ||
var hasCustomBackend = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$use = userConfig.use) === null || _userConfig$use === void 0 ? void 0 : _userConfig$use.some(function (b) { | ||
return b.type === 'backend'; | ||
}); | ||
if (!process.browser && typeof window === 'undefined') { | ||
combinedConfig.preload = locales; | ||
if (!hasCustomBackend) { | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var path = require('path'); // | ||
// | ||
// Validate defaultNS | ||
// https://github.com/i18next/next-i18next/issues/358 | ||
// | ||
if (typeof defaultNS === 'string' && typeof lng !== 'undefined') { | ||
if (typeof localePath === 'string') { | ||
var _userConfig$interpola, _userConfig$interpola2, _userConfig$interpola3, _userConfig$interpola4; | ||
var prefix = (_userConfig$interpola = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$interpola2 = userConfig.interpolation) === null || _userConfig$interpola2 === void 0 ? void 0 : _userConfig$interpola2.prefix) !== null && _userConfig$interpola !== void 0 ? _userConfig$interpola : '{{'; | ||
@@ -143,3 +120,2 @@ var suffix = (_userConfig$interpola3 = userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$interpola4 = userConfig.interpolation) === null || _userConfig$interpola4 === void 0 ? void 0 : _userConfig$interpola4.suffix) !== null && _userConfig$interpola3 !== void 0 ? _userConfig$interpola3 : '}}'; | ||
}); | ||
if (!defaultNSExists && !defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -150,7 +126,4 @@ throw new Error("Default namespace not found at ".concat(defaultNSPath)); | ||
var _defaultNSPath = localePath(lng, defaultNS, false); | ||
var _defaultNSExists = fs.existsSync(_defaultNSPath); | ||
var _fallback = getFallbackForLng(lng, combinedConfig.fallbackLng); | ||
var _defaultFallbackNSExists = _fallback.some(function (f) { | ||
@@ -160,3 +133,2 @@ var defaultNSPath = localePath(f, defaultNS, false); | ||
}); | ||
if (!_defaultNSExists && !_defaultFallbackNSExists && process.env.NODE_ENV !== 'production') { | ||
@@ -166,7 +138,7 @@ throw new Error("Default namespace not found at ".concat(_defaultNSPath)); | ||
} | ||
} // | ||
} | ||
// | ||
// Set server side backend | ||
// | ||
if (typeof localePath === 'string') { | ||
@@ -188,7 +160,7 @@ combinedConfig.backend = { | ||
throw new Error("Unsupported localePath type: ".concat(_typeof(localePath))); | ||
} // | ||
} | ||
// | ||
// Set server side preload (namespaces) | ||
// | ||
if (!combinedConfig.ns && typeof lng !== 'undefined') { | ||
@@ -198,3 +170,2 @@ if (typeof localePath === 'function') { | ||
} | ||
var getNamespaces = function getNamespaces(locales) { | ||
@@ -206,3 +177,2 @@ var getLocaleNamespaces = function getLocaleNamespaces(p) { | ||
var joinedP = path.join(p, file); | ||
if (fs.statSync(joinedP).isDirectory()) { | ||
@@ -215,3 +185,2 @@ var subRet = getLocaleNamespaces(joinedP).map(function (n) { | ||
} | ||
ret.push(file.replace(".".concat(localeExtension), '')); | ||
@@ -221,3 +190,2 @@ }); | ||
}; | ||
var namespacesByLocale = locales.map(function (locale) { | ||
@@ -227,6 +195,4 @@ return getLocaleNamespaces(path.resolve(process.cwd(), "".concat(localePath, "/").concat(locale))); | ||
var allNamespaces = []; | ||
var _iterator = _createForOfIteratorHelper(namespacesByLocale), | ||
_step; | ||
_step; | ||
try { | ||
@@ -242,6 +208,4 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
} | ||
return unique(allNamespaces); | ||
}; | ||
combinedConfig.ns = getNamespaces(unique([lng].concat(_toConsumableArray(getFallbackForLng(lng, combinedConfig.fallbackLng))))); | ||
@@ -271,11 +235,10 @@ } | ||
} | ||
if (typeof combinedConfig.ns !== 'string' && !Array.isArray(combinedConfig.ns)) { | ||
combinedConfig.ns = [defaultNS]; | ||
} | ||
} // | ||
} | ||
// | ||
// Deep merge with overwrite - goes last | ||
// | ||
deepMergeObjects.forEach(function (obj) { | ||
@@ -282,0 +245,0 @@ if (userConfig[obj]) { |
@@ -14,7 +14,5 @@ var DEFAULT_LOCALE = 'en'; | ||
}, | ||
get initImmediate() { | ||
return process.browser && typeof window !== 'undefined'; | ||
}, | ||
interpolation: { | ||
@@ -21,0 +19,0 @@ escapeValue: false |
@@ -6,14 +6,10 @@ import i18n from 'i18next'; | ||
var initPromise; | ||
if (!instance.isInitialized) { | ||
var _config$use; | ||
config === null || config === void 0 ? void 0 : (_config$use = config.use) === null || _config$use === void 0 ? void 0 : _config$use.forEach(function (x) { | ||
return instance.use(x); | ||
}); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -23,3 +19,2 @@ } else { | ||
} | ||
return { | ||
@@ -26,0 +21,0 @@ i18n: instance, |
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
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; } | ||
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; } | ||
import i18n from 'i18next'; | ||
@@ -13,3 +10,2 @@ import i18nextFSBackend from 'i18next-fs-backend'; | ||
var instance; | ||
if (!globalInstance) { | ||
@@ -23,24 +19,17 @@ globalInstance = i18n.createInstance(config); | ||
} | ||
var initPromise; | ||
if (!instance.isInitialized) { | ||
var _config$use, _config$use2; | ||
var hasCustomBackend = config === null || config === void 0 ? void 0 : (_config$use = config.use) === null || _config$use === void 0 ? void 0 : _config$use.some(function (b) { | ||
return b.type === 'backend'; | ||
}); | ||
if (!hasCustomBackend) { | ||
instance.use(i18nextFSBackend); | ||
} | ||
config === null || config === void 0 ? void 0 : (_config$use2 = config.use) === null || _config$use2 === void 0 ? void 0 : _config$use2.forEach(function (x) { | ||
return instance.use(x); | ||
}); | ||
if (typeof config.onPreInitI18next === 'function') { | ||
config.onPreInitI18next(instance); | ||
} | ||
initPromise = instance.init(config); | ||
@@ -50,3 +39,2 @@ } else { | ||
} | ||
return { | ||
@@ -53,0 +41,0 @@ i18n: instance, |
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
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; } | ||
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; } | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { createConfig } from './config/createConfig'; | ||
import createClient from './createClient'; | ||
import createClient from './createClient/node'; | ||
import { globalI18n } from './appWithTranslation'; | ||
@@ -19,18 +16,17 @@ import { getFallbackForLng, unique } from './utils'; | ||
var namespacesRequired, | ||
configOverride, | ||
extraLocales, | ||
userConfig, | ||
config, | ||
localeExtension, | ||
localePath, | ||
fallbackLng, | ||
reloadOnPrerender, | ||
_createClient, | ||
i18n, | ||
initPromise, | ||
initialI18nStore, | ||
getLocaleNamespaces, | ||
namespacesByLocale, | ||
_args = arguments; | ||
configOverride, | ||
extraLocales, | ||
userConfig, | ||
config, | ||
localeExtension, | ||
localePath, | ||
fallbackLng, | ||
reloadOnPrerender, | ||
_createClient, | ||
i18n, | ||
initPromise, | ||
initialI18nStore, | ||
getLocaleNamespaces, | ||
namespacesByLocale, | ||
_args = arguments; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -43,3 +39,2 @@ while (1) { | ||
extraLocales = _args.length > 3 && _args[3] !== undefined ? _args[3] : false; | ||
if (!(typeof initialLocale !== 'string')) { | ||
@@ -49,8 +44,5 @@ _context.next = 5; | ||
} | ||
throw new Error('Initial locale argument was not passed into serverSideTranslations'); | ||
case 5: | ||
userConfig = configOverride; | ||
if (!(!userConfig && fs.existsSync(path.resolve(DEFAULT_CONFIG_PATH)))) { | ||
@@ -60,9 +52,6 @@ _context.next = 10; | ||
} | ||
_context.next = 9; | ||
return import(path.resolve(DEFAULT_CONFIG_PATH)); | ||
case 9: | ||
userConfig = _context.sent; | ||
case 10: | ||
@@ -73,5 +62,3 @@ if (!(userConfig === null)) { | ||
} | ||
throw new Error('next-i18next was unable to find a user config'); | ||
case 12: | ||
@@ -82,3 +69,2 @@ config = createConfig(_objectSpread(_objectSpread({}, userConfig), {}, { | ||
localeExtension = config.localeExtension, localePath = config.localePath, fallbackLng = config.fallbackLng, reloadOnPrerender = config.reloadOnPrerender; | ||
if (!reloadOnPrerender) { | ||
@@ -88,6 +74,4 @@ _context.next = 17; | ||
} | ||
_context.next = 17; | ||
return globalI18n === null || globalI18n === void 0 ? void 0 : globalI18n.reloadResources(); | ||
case 17: | ||
@@ -99,3 +83,2 @@ _createClient = createClient(_objectSpread(_objectSpread({}, config), {}, { | ||
return initPromise; | ||
case 20: | ||
@@ -106,3 +89,2 @@ initialI18nStore = _defineProperty({}, initialLocale, {}); | ||
}); | ||
if (Array.isArray(namespacesRequired)) { | ||
@@ -112,3 +94,2 @@ _context.next = 28; | ||
} | ||
if (!(typeof localePath === 'function')) { | ||
@@ -118,5 +99,3 @@ _context.next = 25; | ||
} | ||
throw new Error('Must provide namespacesRequired to serverSideTranslations when using a function as localePath'); | ||
case 25: | ||
@@ -128,3 +107,2 @@ getLocaleNamespaces = function getLocaleNamespaces(path) { | ||
}; | ||
namespacesByLocale = Object.keys(initialI18nStore).map(function (locale) { | ||
@@ -134,3 +112,2 @@ return getLocaleNamespaces(path.resolve(process.cwd(), "".concat(localePath, "/").concat(locale))); | ||
namespacesRequired = unique(namespacesByLocale); | ||
case 28: | ||
@@ -150,3 +127,2 @@ namespacesRequired.forEach(function (ns) { | ||
}); | ||
case 30: | ||
@@ -159,3 +135,2 @@ case "end": | ||
})); | ||
return function serverSideTranslations(_x) { | ||
@@ -162,0 +137,0 @@ return _ref.apply(this, arguments); |
/* tslint:disable no-explicit-any */ | ||
import { I18nContext, useTranslation, Trans, withTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { I18nContext, useTranslation, Trans, withTranslation, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { appWithTranslation, i18n } from './'; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace }; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, DefaultNamespace }; |
@@ -7,7 +7,5 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
} | ||
if (Array.isArray(fallbackLng)) { | ||
return fallbackLng; | ||
} | ||
if (_typeof(fallbackLng) === 'object') { | ||
@@ -18,7 +16,5 @@ var fallbackList = fallbackLng[lng]; | ||
} | ||
if (typeof fallbackLng === 'function') { | ||
return getFallbackForLng(lng, fallbackLng(lng)); | ||
} | ||
return []; | ||
@@ -25,0 +21,0 @@ }; |
@@ -7,6 +7,5 @@ import React from 'react'; | ||
export { Trans, useTranslation, withTranslation } from 'react-i18next'; | ||
declare type AppProps = NextJsAppProps & { | ||
pageProps: SSRConfig; | ||
}; | ||
export declare let globalI18n: I18NextClient | null; | ||
export declare const appWithTranslation: <Props extends AppProps = AppProps>(WrappedComponent: React.ComponentType<Props>, configOverride?: UserConfig | null) => ((props: Props) => JSX.Element) & hoistNonReactStatics.NonReactStatics<React.ComponentType<Props>, {}>; | ||
export declare const appWithTranslation: <Props extends NextJsAppProps<any>>(WrappedComponent: React.ComponentType<Props>, configOverride?: UserConfig | null) => ((props: Props & { | ||
pageProps: Props["pageProps"] & SSRConfig; | ||
}) => JSX.Element) & hoistNonReactStatics.NonReactStatics<React.ComponentType<Props>, {}>; |
@@ -1,9 +0,9 @@ | ||
import { I18nContext, useTranslation, Trans, withTranslation, WithTranslation as ReactI18nextWithTranslation, Resources, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { I18nContext, useTranslation, Trans, withTranslation, WithTranslation as ReactI18nextWithTranslation, DefaultNamespace, Translation } from 'react-i18next'; | ||
import { InitOptions, i18n as I18NextClient, TFunction as I18NextTFunction } from 'i18next'; | ||
import { appWithTranslation, i18n } from './'; | ||
declare type NextJsI18NConfig = { | ||
type NextJsI18NConfig = { | ||
defaultLocale: string; | ||
locales: string[]; | ||
}; | ||
export declare type UserConfig = { | ||
export type UserConfig = { | ||
i18n: NextJsI18NConfig; | ||
@@ -18,3 +18,3 @@ localeExtension?: string; | ||
} & InitOptions; | ||
export declare type InternalConfig = Omit<UserConfig, 'i18n'> & NextJsI18NConfig & { | ||
export type InternalConfig = Omit<UserConfig, 'i18n'> & NextJsI18NConfig & { | ||
errorStackTraceLimit: number; | ||
@@ -24,15 +24,15 @@ preload: string[]; | ||
}; | ||
export declare type UseTranslation = typeof useTranslation; | ||
export declare type AppWithTranslation = typeof appWithTranslation; | ||
export declare type TFunction = I18NextTFunction; | ||
export declare type I18n = I18NextClient; | ||
export declare type WithTranslationHocType = typeof withTranslation; | ||
export declare type WithTranslation = ReactI18nextWithTranslation; | ||
export declare type InitPromise = Promise<TFunction>; | ||
export declare type CreateClientReturn = { | ||
export type UseTranslation = typeof useTranslation; | ||
export type AppWithTranslation = typeof appWithTranslation; | ||
export type TFunction = I18NextTFunction; | ||
export type I18n = I18NextClient; | ||
export type WithTranslationHocType = typeof withTranslation; | ||
export type WithTranslation = ReactI18nextWithTranslation; | ||
export type InitPromise = Promise<TFunction>; | ||
export type CreateClientReturn = { | ||
i18n: I18n; | ||
initPromise: InitPromise; | ||
}; | ||
export declare type SSRConfig = { | ||
_nextI18Next: { | ||
export type SSRConfig = { | ||
_nextI18Next?: { | ||
initialI18nStore: any; | ||
@@ -44,2 +44,2 @@ initialLocale: string; | ||
}; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, Resources, DefaultNamespace, }; | ||
export { i18n, I18nContext, appWithTranslation, useTranslation, Trans, Translation, withTranslation, DefaultNamespace, }; |
118
package.json
{ | ||
"name": "next-i18next", | ||
"version": "12.1.0", | ||
"version": "13.0.0", | ||
"repository": "git@github.com:i18next/next-i18next.git", | ||
@@ -9,2 +9,6 @@ "author": "i18next", | ||
"type": "individual", | ||
"url": "https://github.com/belgattitude" | ||
}, | ||
{ | ||
"type": "individual", | ||
"url": "https://locize.com" | ||
@@ -26,3 +30,3 @@ }, | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=14" | ||
}, | ||
@@ -41,5 +45,4 @@ "description": "The easiest way to translate your NextJs apps.", | ||
"scripts": { | ||
"check-types": "tsc --noEmit", | ||
"lint": "eslint src examples", | ||
"clean": "rm -rf examples/simple/.next && rm -rf examples/ssg/.next && rm -rf dist && mkdir dist", | ||
"clean": "rm -rf ./examples/simple/.next ./examples/ssg/.next ./dist && mkdir dist", | ||
"build:es": "BABEL_ENV=es babel src --extensions '.ts,.tsx' --out-dir dist/es --copy-files", | ||
@@ -49,9 +52,20 @@ "build:cjs": "BABEL_ENV=cjs babel src --extensions '.ts,.tsx' --out-dir dist/commonjs --copy-files", | ||
"build:types": "tsc --noEmit false --declaration --emitDeclarationOnly --outDir dist/types", | ||
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:esm && npm run build:types", | ||
"build": "npm-run-all -s clean build:cjs build:es build:esm build:types", | ||
"build:examples": "npm-run-all -s build:example:*", | ||
"build:example:simple": "cd examples/simple && npm run build", | ||
"build:example:ssg": "cd examples/ssg && npm run build", | ||
"typecheck": "tsc --project ./tsconfig.json --noEmit", | ||
"check-size": "size-limit", | ||
"check-size:why": "size-limit --why", | ||
"check-dist": "npm-run-all -s check-dist:*", | ||
"check-dist:browser-cjs": "es-check --not 'dist/**/*.map.js,dist/commonjs/createClient/package.json,dist/commonjs/**node**.js,dist/commonjs/serverSideTranslations.js' -v es2017 './dist/commonjs/**/*'", | ||
"check-dist:browser-esm": "es-check --not 'dist/**/*.map.js,dist/esm/createClient/package.json,dist/**node**.js,dist/esm/serverSideTranslations.js' -v es2017 --module './dist/esm/**/*'", | ||
"test": "NODE_ENV=test jest --maxWorkers=1 --silent", | ||
"install:examples": "npm-run-all -s install:example:*", | ||
"install:example:simple": "cd examples/simple && npm install", | ||
"install:example:ssg": "cd examples/ssg && npm install", | ||
"install:examples": "npm run install:example:simple && npm run install:example:ssg", | ||
"prepublishOnly": "npm run build", | ||
"move-build-to-examples?": "Hack: see # @link https://github.com/i18next/next-i18next/pull/2012", | ||
"move-build-to-examples": "rimraf ./examples/*/node_modules/next-i18next && cpy './package.json' './*.js' './*.ts' './dist' ./examples/simple/node_modules/next-i18next && cpy './package.json' './*.js' './*.ts' './dist' ./examples/ssg/node_modules/next-i18next", | ||
"test:e2e": "start-server-and-test 'cd examples/simple && npm run start' http://127.0.0.1:3000 cy:run", | ||
"cy:run": "cypress run", | ||
"example": "npm run example:simple", | ||
@@ -63,5 +77,3 @@ "example:prod": "npm run example:simple:prod", | ||
"example:ssg:prod": "npm run build:example:ssg && cd examples/ssg && npm run start", | ||
"cypress": "cypress run --config-file cypress/cypress.json", | ||
"test": "npm run check-types && npm run clean && npm run build && npm run build:example:simple && bundlesize && NODE_ENV=test jest --maxWorkers=1 --silent", | ||
"test:e2e": "start-server-and-test 'cd examples/simple && npm run start' 3000 'npm run cypress'", | ||
"prepublishOnly": "npm run build", | ||
"contributors:check": "all-contributors check", | ||
@@ -72,34 +84,19 @@ "contributors:add": "all-contributors add", | ||
"postversion": "git push && git push --tags && npm run release", | ||
"release": "gh-release" | ||
"release": "gh-release", | ||
"nuke:install": "rimraf '**/node_modules' '**/package-lock.json'", | ||
"prepare": "husky install" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run lint" | ||
} | ||
}, | ||
"bundlesize": [ | ||
{ | ||
"path": "./examples/simple/.next/static/chunks/*.js", | ||
"maxSize": "50 kB" | ||
}, | ||
{ | ||
"path": "./examples/simple/.next/static/chunks/main*.js", | ||
"maxSize": "35 kB" | ||
}, | ||
{ | ||
"path": "./examples/simple/.next/static/chunks/webpack*.js", | ||
"maxSize": "770 B" | ||
} | ||
], | ||
"devDependencies": { | ||
"@babel/cli": "^7.18.10", | ||
"@babel/core": "^7.18.10", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-transform-runtime": "^7.18.10", | ||
"@babel/preset-env": "^7.18.10", | ||
"@babel/preset-react": "^7.18.6", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@babel/cli": "7.18.10", | ||
"@babel/core": "7.18.10", | ||
"@babel/plugin-proposal-class-properties": "7.18.6", | ||
"@babel/plugin-transform-runtime": "7.18.10", | ||
"@babel/preset-env": "7.18.10", | ||
"@babel/preset-react": "7.18.6", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@size-limit/file": "^8.1.0", | ||
"@size-limit/webpack": "^8.1.0", | ||
"@size-limit/webpack-why": "^8.1.0", | ||
"@testing-library/react": "^13.3.0", | ||
"@types/i18next-fs-backend": "^1.1.2", | ||
"@types/jest": "^28.1.7", | ||
"@types/jest": "^29.2.2", | ||
"@types/node": "^18.7.8", | ||
@@ -112,11 +109,12 @@ "@types/react": "^18.0.17", | ||
"all-contributors-cli": "^6.20.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"bundlesize": "^0.18.1", | ||
"cypress": "^9.1.1", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-plugin-add-module-exports": "1.0.4", | ||
"babel-plugin-transform-async-to-generator": "6.24.1", | ||
"cpy-cli": "^4.2.0", | ||
"cypress": "^11.0.1", | ||
"es-check": "^7.0.1", | ||
"eslint": "^8.22.0", | ||
"eslint-plugin-cypress": "^2.12.1", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.8.5", | ||
"eslint-plugin-jest": "^27.1.4", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
@@ -126,9 +124,16 @@ "eslint-plugin-react": "^7.30.1", | ||
"gh-release": "6.0.4", | ||
"husky": "^3.0.0", | ||
"jest": "^26.6.3", | ||
"next": "^12.2.5", | ||
"husky": "^8.0.2", | ||
"i18next": "^22.0.6", | ||
"jest": "^29.3.1", | ||
"jest-environment-jsdom": "^29.3.1", | ||
"next": "^13.0.2", | ||
"npm-run-all": "^4.1.5", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-i18next": "^12.0.0", | ||
"rimraf": "^3.0.2", | ||
"size-limit": "^8.1.0", | ||
"start-server-and-test": "^1.14.0", | ||
"typescript": "^4.7.4" | ||
"typescript": "^4.9.3", | ||
"webpack": "^5.74.0" | ||
}, | ||
@@ -140,15 +145,10 @@ "dependencies": { | ||
"hoist-non-react-statics": "^3.3.2", | ||
"i18next": "^21.9.1", | ||
"i18next-fs-backend": "^1.1.5", | ||
"react-i18next": "^11.18.4" | ||
"i18next-fs-backend": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"next": ">= 10.0.0", | ||
"react": ">= 16.8.0" | ||
}, | ||
"resolutions": { | ||
"i18next": ">=21.8.14", | ||
"i18next-fs-backend": ">=1.1.4", | ||
"react-i18next": ">=11.18.3" | ||
"i18next": "^22.0.6", | ||
"next": ">= 12.0.0", | ||
"react": ">= 17.0.2", | ||
"react-i18next": "^12.0.0" | ||
} | ||
} |
@@ -44,4 +44,4 @@ # next-i18next | ||
```jsx | ||
yarn add next-i18next | ||
```bash | ||
yarn add next-i18next react-i18next i18next | ||
``` | ||
@@ -159,3 +159,3 @@ | ||
To do that, you can pass an array of required namespaces for each page into `serverSideTranslations`. You can see this approach in [examples/simple/pages/index.js](./examples/simple/pages/index.js). Passing in an empty array of required namespaces will send no namespaces. | ||
To do that, you can pass an array of required namespaces for each page into `serverSideTranslations`. You can see this approach in [examples/simple/pages/index.tsx](./examples/simple/pages/index.tsx). Passing in an empty array of required namespaces will send no namespaces. | ||
@@ -220,4 +220,2 @@ Note: `useTranslation` provides namespaces to the component that you use it in. However, `serverSideTranslations` provides the total available namespaces to the entire React tree and belongs on the page level. Both are required. | ||
```js | ||
const path = require('path'); | ||
module.exports = { | ||
@@ -228,9 +226,11 @@ i18n: { | ||
}, | ||
localePath: path.resolve('./my/custom/path'), | ||
localePath: typeof window === 'undefined' ? | ||
require('path').resolve('./my-custom/path'): | ||
'/public/my-custom/path', | ||
}; | ||
``` | ||
#### Unserialisable configs | ||
#### Unserializable configs | ||
Some `i18next` plugins (which you can pass into `config.use`) are unserialisable, as they contain functions and other JavaScript primitives. | ||
Some `i18next` plugins (which you can pass into `config.use`) are unserializable, as they contain functions and other JavaScript primitives. | ||
@@ -374,11 +374,18 @@ You may run into this if your use case is more advanced. You'll see Next.js throw an error like: | ||
<table> | ||
<tr> | ||
<td align="center"><a href="https://locize.com/"><img src="https://avatars.githubusercontent.com/u/1086194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Adriano Raiano</b></sub></a><br /><a href="#question-adrai" title="Answering Questions">💬</a> <a href="#blog-adrai" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aadrai" title="Bug reports">🐛</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Documentation">📖</a> <a href="#example-adrai" title="Examples">💡</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aadrai" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Tests">⚠️</a> <a href="#tutorial-adrai" title="Tutorials">✅</a></td> | ||
<td align="center"><a href="https://isaachinman.com/"><img src="https://avatars.githubusercontent.com/u/10575782?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Isaac Hinman</b></sub></a><br /><a href="#question-isaachinman" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Code">💻</a> <a href="#content-isaachinman" title="Content">🖋</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Documentation">📖</a> <a href="#example-isaachinman" title="Examples">💡</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aisaachinman" title="Reviewed Pull Requests">👀</a></td> | ||
<td align="center"><a href="https://github.com/capellini"><img src="https://avatars3.githubusercontent.com/u/75311?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rob Capellini</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://en.kachkaev.ru"><img src="https://avatars3.githubusercontent.com/u/608862?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexander Kachkaev</b></sub></a><br /><a href="#talk-kachkaev" title="Talks">📢</a> <a href="#question-kachkaev" title="Answering Questions">💬</a> <a href="#ideas-kachkaev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://github.com/felixmosh"><img src="https://avatars.githubusercontent.com/u/9304194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Felix Mosheev</b></sub></a><br /><a href="#question-felixmosh" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Code">💻</a> <a href="#talk-felixmosh" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://kandelborg.dk"><img src="https://avatars1.githubusercontent.com/u/33042011?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mathias Wøbbe</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Code">💻</a> <a href="#ideas-MathiasKandelborg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="http://lucasfeliciano.com"><img src="https://avatars3.githubusercontent.com/u/968014?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lucas Feliciano</b></sub></a><br /><a href="#ideas-lucasfeliciano" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Alucasfeliciano" title="Reviewed Pull Requests">👀</a></td> | ||
</tr> | ||
<tbody> | ||
<tr> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/capellini"><img src="https://avatars3.githubusercontent.com/u/75311?v=4?s=100" width="100px;" alt="Rob Capellini"/><br /><sub><b>Rob Capellini</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Tests">⚠️</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://en.kachkaev.ru"><img src="https://avatars3.githubusercontent.com/u/608862?v=4?s=100" width="100px;" alt="Alexander Kachkaev"/><br /><sub><b>Alexander Kachkaev</b></sub></a><br /><a href="#talk-kachkaev" title="Talks">📢</a> <a href="#question-kachkaev" title="Answering Questions">💬</a> <a href="#ideas-kachkaev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Tests">⚠️</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://kandelborg.dk"><img src="https://avatars1.githubusercontent.com/u/33042011?v=4?s=100" width="100px;" alt="Mathias Wøbbe"/><br /><sub><b>Mathias Wøbbe</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Code">💻</a> <a href="#ideas-MathiasKandelborg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Tests">⚠️</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="http://lucasfeliciano.com"><img src="https://avatars3.githubusercontent.com/u/968014?v=4?s=100" width="100px;" alt="Lucas Feliciano"/><br /><sub><b>Lucas Feliciano</b></sub></a><br /><a href="#ideas-lucasfeliciano" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Alucasfeliciano" title="Reviewed Pull Requests">👀</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="http://www.fifteenprospects.com"><img src="https://avatars2.githubusercontent.com/u/6932550?v=4?s=100" width="100px;" alt="Ryan Leung"/><br /><sub><b>Ryan Leung</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=minocys" title="Code">💻</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="http://nathanfriemel.com"><img src="https://avatars3.githubusercontent.com/u/1325835?v=4?s=100" width="100px;" alt="Nathan Friemel"/><br /><sub><b>Nathan Friemel</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=nathanfriemel" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=nathanfriemel" title="Documentation">📖</a> <a href="#example-nathanfriemel" title="Examples">💡</a> <a href="#ideas-nathanfriemel" title="Ideas, Planning, & Feedback">🤔</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://isaachinman.com/"><img src="https://avatars.githubusercontent.com/u/10575782?v=4?s=100" width="100px;" alt="Isaac Hinman"/><br /><sub><b>Isaac Hinman</b></sub></a><br /><a href="#a11y-isaachinman" title="Accessibility">️️️️♿️</a> <a href="#question-isaachinman" title="Answering Questions">💬</a> <a href="#audio-isaachinman" title="Audio">🔊</a> <a href="#blog-isaachinman" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aisaachinman" title="Bug reports">🐛</a> <a href="#business-isaachinman" title="Business development">💼</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Code">💻</a> <a href="#content-isaachinman" title="Content">🖋</a> <a href="#data-isaachinman" title="Data">🔣</a> <a href="#design-isaachinman" title="Design">🎨</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Documentation">📖</a> <a href="#eventOrganizing-isaachinman" title="Event Organizing">📋</a> <a href="#example-isaachinman" title="Examples">💡</a> <a href="#financial-isaachinman" title="Financial">💵</a> <a href="#fundingFinding-isaachinman" title="Funding Finding">🔍</a> <a href="#ideas-isaachinman" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-isaachinman" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-isaachinman" title="Maintenance">🚧</a> <a href="#mentoring-isaachinman" title="Mentoring">🧑🏫</a> <a href="#platform-isaachinman" title="Packaging/porting to new platform">📦</a> <a href="#plugin-isaachinman" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-isaachinman" title="Project Management">📆</a> <a href="#research-isaachinman" title="Research">🔬</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aisaachinman" title="Reviewed Pull Requests">👀</a> <a href="#security-isaachinman" title="Security">🛡️</a> <a href="#talk-isaachinman" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Tests">⚠️</a> <a href="#tool-isaachinman" title="Tools">🔧</a> <a href="#translation-isaachinman" title="Translation">🌍</a> <a href="#tutorial-isaachinman" title="Tutorials">✅</a> <a href="#userTesting-isaachinman" title="User Testing">📓</a> <a href="#video-isaachinman" title="Videos">📹</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center" valign="top" width="14.28%"><a href="https://locize.com/"><img src="https://avatars.githubusercontent.com/u/1086194?v=4?s=100" width="100px;" alt="Adriano Raiano"/><br /><sub><b>Adriano Raiano</b></sub></a><br /><a href="#a11y-adrai" title="Accessibility">️️️️♿️</a> <a href="#question-adrai" title="Answering Questions">💬</a> <a href="#audio-adrai" title="Audio">🔊</a> <a href="#blog-adrai" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aadrai" title="Bug reports">🐛</a> <a href="#business-adrai" title="Business development">💼</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Code">💻</a> <a href="#content-adrai" title="Content">🖋</a> <a href="#data-adrai" title="Data">🔣</a> <a href="#design-adrai" title="Design">🎨</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Documentation">📖</a> <a href="#eventOrganizing-adrai" title="Event Organizing">📋</a> <a href="#example-adrai" title="Examples">💡</a> <a href="#financial-adrai" title="Financial">💵</a> <a href="#fundingFinding-adrai" title="Funding Finding">🔍</a> <a href="#ideas-adrai" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-adrai" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-adrai" title="Maintenance">🚧</a> <a href="#mentoring-adrai" title="Mentoring">🧑🏫</a> <a href="#platform-adrai" title="Packaging/porting to new platform">📦</a> <a href="#plugin-adrai" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-adrai" title="Project Management">📆</a> <a href="#research-adrai" title="Research">🔬</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aadrai" title="Reviewed Pull Requests">👀</a> <a href="#security-adrai" title="Security">🛡️</a> <a href="#talk-adrai" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Tests">⚠️</a> <a href="#tool-adrai" title="Tools">🔧</a> <a href="#translation-adrai" title="Translation">🌍</a> <a href="#tutorial-adrai" title="Tutorials">✅</a> <a href="#userTesting-adrai" title="User Testing">📓</a> <a href="#video-adrai" title="Videos">📹</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/felixmosh"><img src="https://avatars.githubusercontent.com/u/9304194?v=4?s=100" width="100px;" alt="Felix Mosheev"/><br /><sub><b>Felix Mosheev</b></sub></a><br /><a href="#question-felixmosh" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Code">💻</a> <a href="#talk-felixmosh" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Tests">⚠️</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://soluble.io/pro"><img src="https://avatars.githubusercontent.com/u/259798?v=4?s=100" width="100px;" alt="Sébastien Vanvelthem"/><br /><sub><b>Sébastien Vanvelthem</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=belgattitude" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=belgattitude" title="Documentation">📖</a> <a href="#example-belgattitude" title="Examples">💡</a> <a href="#maintenance-belgattitude" title="Maintenance">🚧</a> <a href="#userTesting-belgattitude" title="User Testing">📓</a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
@@ -388,2 +395,3 @@ | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -390,0 +398,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126432
45
1929
419
47
15
+ Addedi18next@22.5.1(transitive)
+ Addedi18next-fs-backend@2.3.2(transitive)
+ Addedreact-i18next@12.3.1(transitive)
- Removedi18next@^21.9.1
- Removedreact-i18next@^11.18.4
- Removedi18next@21.10.0(transitive)
- Removedi18next-fs-backend@1.2.0(transitive)
- Removedreact-i18next@11.18.6(transitive)
Updatedi18next-fs-backend@^2.0.0