next-translate 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "i18nrequeststore",
3
+ "private": true,
4
+ "main": "../lib/cjs/i18nRequestStore.js",
5
+ "module": "../lib/esm/i18nRequestStore.js",
6
+ "types": "../i18nRequestStore.d.ts"
7
+ }
@@ -0,0 +1,4 @@
1
+ import { I18nDictionary } from '.';
2
+ type NamespaceStore = Record<string, I18nDictionary>;
3
+ export declare function getRequestNamespaces(): NamespaceStore;
4
+ export {};
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  function AppDirI18nProvider(_a) {
5
5
  var lang = _a.lang, _b = _a.namespaces, namespaces = _b === void 0 ? {} : _b, config = _a.config, children = _a.children;
6
- if (typeof window !== 'undefined') {
7
- globalThis.__NEXT_TRANSLATE__ = { lang: lang, namespaces: namespaces, config: config };
8
- }
6
+ globalThis.__NEXT_TRANSLATE__ = { lang: lang, namespaces: namespaces, config: config };
9
7
  return children;
10
8
  }
11
9
  exports.default = AppDirI18nProvider;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getRequestNamespaces = void 0;
15
+ var createRequestStore;
16
+ try {
17
+ var React_1 = require('react');
18
+ if (typeof React_1.cache === 'function') {
19
+ createRequestStore = React_1.cache(function () { return ({}); });
20
+ }
21
+ }
22
+ catch (_a) { }
23
+ if (!createRequestStore) {
24
+ createRequestStore = function () {
25
+ var _a, _b;
26
+ return (__assign({}, ((_b = (_a = globalThis.__NEXT_TRANSLATE__) === null || _a === void 0 ? void 0 : _a.namespaces) !== null && _b !== void 0 ? _b : {})));
27
+ };
28
+ }
29
+ function getRequestNamespaces() {
30
+ return createRequestStore();
31
+ }
32
+ exports.getRequestNamespaces = getRequestNamespaces;
@@ -1,8 +1,6 @@
1
1
  'use client';
2
2
  export default function AppDirI18nProvider(_a) {
3
3
  var lang = _a.lang, _b = _a.namespaces, namespaces = _b === void 0 ? {} : _b, config = _a.config, children = _a.children;
4
- if (typeof window !== 'undefined') {
5
- globalThis.__NEXT_TRANSLATE__ = { lang: lang, namespaces: namespaces, config: config };
6
- }
4
+ globalThis.__NEXT_TRANSLATE__ = { lang: lang, namespaces: namespaces, config: config };
7
5
  return children;
8
6
  }
@@ -0,0 +1,28 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var createRequestStore;
13
+ try {
14
+ var React_1 = require('react');
15
+ if (typeof React_1.cache === 'function') {
16
+ createRequestStore = React_1.cache(function () { return ({}); });
17
+ }
18
+ }
19
+ catch (_a) { }
20
+ if (!createRequestStore) {
21
+ createRequestStore = function () {
22
+ var _a, _b;
23
+ return (__assign({}, ((_b = (_a = globalThis.__NEXT_TRANSLATE__) === null || _a === void 0 ? void 0 : _a.namespaces) !== null && _b !== void 0 ? _b : {})));
24
+ };
25
+ }
26
+ export function getRequestNamespaces() {
27
+ return createRequestStore();
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-translate",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -105,6 +105,11 @@
105
105
  "types": "./formatElements.d.ts",
106
106
  "import": "./lib/esm/formatElements.js",
107
107
  "require": "./lib/cjs/formatElements.js"
108
+ },
109
+ "./i18nRequestStore": {
110
+ "types": "./i18nRequestStore.d.ts",
111
+ "import": "./lib/esm/i18nRequestStore.js",
112
+ "require": "./lib/cjs/i18nRequestStore.js"
108
113
  }
109
114
  },
110
115
  "files": [
@@ -124,12 +129,13 @@
124
129
  "index",
125
130
  "AppDirI18nProvider",
126
131
  "createTranslation",
127
- "formatElements"
132
+ "formatElements",
133
+ "i18nRequestStore"
128
134
  ],
129
135
  "scripts": {
130
136
  "build": "yarn clean && cross-env NODE_ENV=production && yarn tsc",
131
137
  "clean": "yarn clean:build && yarn clean:examples",
132
- "clean:build": "del lib appWith* Dynamic* I18n* index context loadNa* setLang* Trans* useT* withT* getP* getC* *.d.ts getT transC* wrapT* types formatElements isServer AppDirI18nProvider* createTrans*",
138
+ "clean:build": "del lib appWith* Dynamic* I18n* i18nStore* i18nRequestStore* index context loadNa* setLang* Trans* useT* withT* getP* getC* *.d.ts getT transC* wrapT* types formatElements isServer AppDirI18nProvider* createTrans*",
133
139
  "clean:examples": "del examples/**/.next examples/**/node_modules examples/**/yarn.lock",
134
140
  "example": "yarn example:complex",
135
141
  "example:basic": "yarn build && yarn --cwd examples/basic && yarn --cwd examples/basic dev",