Socket
Socket
Sign inDemoInstall

next-i18next

Package Overview
Dependencies
Maintainers
1
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-i18next - npm Package Compare versions

Comparing version 0.38.0 to 0.39.0

dist/commonjs/utils/lngs-to-load.js

39

dist/commonjs/hocs/app-with-translation.js

@@ -104,3 +104,3 @@ "use strict";

_regenerator.default.mark(function _callee(ctx) {
var wrappedComponentProps, req, initialI18nStore, initialLanguage, i18nServerInstance, namespacesRequired, fallbackLng;
var wrappedComponentProps, req, initialI18nStore, initialLanguage, i18nServerInstance, namespacesRequired, fallbackLng, languagesToLoad;
return _regenerator.default.wrap(function _callee$(_context) {

@@ -175,32 +175,27 @@ while (1) {

if (!(req && req.i18n)) {
_context.next = 27;
_context.next = 26;
break;
}
// Initialise the store with only the initialLanguage and
// Detect the languages to load based upon the fallbackLng configuration
fallbackLng = config.fallbackLng;
languagesToLoad = (0, _utils.lngsToLoad)(initialLanguage, fallbackLng); // Initialise the store with the languagesToLoad and
// necessary namespaces needed to render this specific tree
fallbackLng = config.fallbackLng;
initialI18nStore[initialLanguage] = {};
if (fallbackLng) {
initialI18nStore[fallbackLng] = {};
}
namespacesRequired.forEach(function (ns) {
initialI18nStore[initialLanguage][ns] = (req.i18n.services.resourceStore.data[initialLanguage] || {})[ns] || {};
if (fallbackLng) {
initialI18nStore[fallbackLng][ns] = (req.i18n.services.resourceStore.data[fallbackLng] || {})[ns] || {};
}
languagesToLoad.forEach(function (lng) {
initialI18nStore[lng] = {};
namespacesRequired.forEach(function (ns) {
initialI18nStore[lng][ns] = (req.i18n.services.resourceStore.data[lng] || {})[ns] || {};
});
});
_context.next = 31;
_context.next = 30;
break;
case 27:
case 26:
if (!(Array.isArray(i18n.languages) && i18n.languages.length > 0)) {
_context.next = 31;
_context.next = 30;
break;
}
_context.next = 30;
_context.next = 29;
return Promise.all(namespacesRequired.filter(function (ns) {

@@ -216,6 +211,6 @@ return !i18n.hasResourceBundle(i18n.languages[0], ns);

case 30:
case 29:
initialI18nStore = i18n.store.data;
case 31:
case 30:
// Step 4: Overwrite i18n.toJSON method to be able to serialize the instance

@@ -237,3 +232,3 @@ if (req && req.i18n) {

case 33:
case 32:
case "end":

@@ -240,0 +235,0 @@ return _context.stop();

@@ -38,2 +38,8 @@ "use strict";

});
Object.defineProperty(exports, "lngsToLoad", {
enumerable: true,
get: function get() {
return _lngsToLoad.default;
}
});
Object.defineProperty(exports, "localeSubpathRequired", {

@@ -62,4 +68,6 @@ enumerable: true,

var _lngsToLoad = _interopRequireDefault(require("./lngs-to-load"));
var _localeSubpathRequired = _interopRequireDefault(require("./locale-subpath-required"));
var _redirectWithoutCache = _interopRequireDefault(require("./redirect-without-cache"));

@@ -5,3 +5,3 @@ import React from 'react';

import { I18nextProvider } from 'react-i18next';
import { lngFromReq, lngPathCorrector } from '../utils';
import { lngFromReq, lngPathCorrector, lngsToLoad } from '../utils';
import { localeSubpathOptions } from '../config/default-config';

@@ -101,19 +101,14 @@ import { NextStaticProvider } from '../components';

if (req && req.i18n) {
// Initialise the store with only the initialLanguage and
// necessary namespaces needed to render this specific tree
// Detect the languages to load based upon the fallbackLng configuration
const {
fallbackLng
} = config;
initialI18nStore[initialLanguage] = {};
const languagesToLoad = lngsToLoad(initialLanguage, fallbackLng); // Initialise the store with the languagesToLoad and
// necessary namespaces needed to render this specific tree
if (fallbackLng) {
initialI18nStore[fallbackLng] = {};
}
namespacesRequired.forEach(ns => {
initialI18nStore[initialLanguage][ns] = (req.i18n.services.resourceStore.data[initialLanguage] || {})[ns] || {};
if (fallbackLng) {
initialI18nStore[fallbackLng][ns] = (req.i18n.services.resourceStore.data[fallbackLng] || {})[ns] || {};
}
languagesToLoad.forEach(lng => {
initialI18nStore[lng] = {};
namespacesRequired.forEach(ns => {
initialI18nStore[lng][ns] = (req.i18n.services.resourceStore.data[lng] || {})[ns] || {};
});
});

@@ -120,0 +115,0 @@ } else if (Array.isArray(i18n.languages) && i18n.languages.length > 0) {

@@ -6,3 +6,4 @@ export { default as consoleMessage } from './console-message.js';

export { default as lngPathDetector } from './lng-path-detector';
export { default as lngsToLoad } from './lngs-to-load';
export { default as localeSubpathRequired } from './locale-subpath-required';
export { default as redirectWithoutCache } from './redirect-without-cache';
{
"name": "next-i18next",
"version": "0.38.0",
"version": "0.39.0",
"repository": "git@github.com:isaachinman/next-i18next.git",

@@ -5,0 +5,0 @@ "author": "Isaac Hinman <isaac@isaachinman.com>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc