next-intl 3.5.1 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/react-server/getTranslator.js +2 -5
- package/dist/development/server/react-server/getTranslations.js +2 -0
- package/dist/development/shared/constants.js +1 -1
- package/dist/development/shared/messageFormatCache.js +12 -0
- package/dist/esm/react-server/getTranslator.js +1 -1
- package/dist/esm/server/react-server/getTranslations.js +1 -1
- package/dist/esm/shared/constants.js +1 -1
- package/dist/esm/shared/messageFormatCache.js +1 -0
- package/dist/production/react-server/getTranslator.js +1 -1
- package/dist/production/server/react-server/getTranslations.js +1 -1
- package/dist/production/shared/constants.js +1 -1
- package/dist/production/shared/messageFormatCache.js +1 -0
- package/dist/types/__mocks__/react.d.ts +1 -1
- package/dist/types/src/shared/constants.d.ts +1 -1
- package/dist/types/src/shared/messageFormatCache.d.ts +3 -0
- package/package.json +3 -3
|
@@ -4,15 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var core = require('use-intl/core');
|
|
7
|
+
var messageFormatCache = require('../shared/messageFormatCache.js');
|
|
7
8
|
|
|
8
|
-
function getMessageFormatCacheImpl() {
|
|
9
|
-
return new Map();
|
|
10
|
-
}
|
|
11
|
-
const getMessageFormatCache = React.cache(getMessageFormatCacheImpl);
|
|
12
9
|
function getTranslatorImpl(config, namespace) {
|
|
13
10
|
return core.createTranslator({
|
|
14
11
|
...config,
|
|
15
|
-
messageFormatCache: getMessageFormatCache(),
|
|
12
|
+
messageFormatCache: messageFormatCache.getMessageFormatCache(),
|
|
16
13
|
namespace
|
|
17
14
|
});
|
|
18
15
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var core = require('use-intl/core');
|
|
7
|
+
var messageFormatCache = require('../../shared/messageFormatCache.js');
|
|
7
8
|
var getConfig = require('./getConfig.js');
|
|
8
9
|
var getLocale = require('./getLocale.js');
|
|
9
10
|
|
|
@@ -26,6 +27,7 @@ async function getTranslations(namespaceOrOpts) {
|
|
|
26
27
|
const config = await getConfig.default(locale || (await getLocale.default()));
|
|
27
28
|
return core.createTranslator({
|
|
28
29
|
...config,
|
|
30
|
+
messageFormatCache: messageFormatCache.getMessageFormatCache(),
|
|
29
31
|
namespace,
|
|
30
32
|
messages: config.messages
|
|
31
33
|
});
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
// https://nextjs.org/docs/advanced-features/i18n-routing#leveraging-the-next_locale-cookie
|
|
7
7
|
const COOKIE_LOCALE_NAME = 'NEXT_LOCALE';
|
|
8
8
|
const COOKIE_MAX_AGE = 31536000; // 1 year
|
|
9
|
-
const COOKIE_SAME_SITE = '
|
|
9
|
+
const COOKIE_SAME_SITE = 'lax';
|
|
10
10
|
|
|
11
11
|
// Should take precedence over the cookie
|
|
12
12
|
const HEADER_LOCALE_NAME = 'X-NEXT-INTL-LOCALE';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function getMessageFormatCacheImpl() {
|
|
8
|
+
return new Map();
|
|
9
|
+
}
|
|
10
|
+
const getMessageFormatCache = React.cache(getMessageFormatCacheImpl);
|
|
11
|
+
|
|
12
|
+
exports.getMessageFormatCache = getMessageFormatCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import{createTranslator as r}from"use-intl/core";
|
|
1
|
+
import{cache as e}from"react";import{createTranslator as r}from"use-intl/core";import{getMessageFormatCache as a}from"../shared/messageFormatCache.js";var m=e((function(e,m){return r({...e,messageFormatCache:a(),namespace:m})}));export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import{createTranslator as
|
|
1
|
+
import{cache as e}from"react";import{createTranslator as a}from"use-intl/core";import{getMessageFormatCache as s}from"../../shared/messageFormatCache.js";import t from"./getConfig.js";import o from"./getLocale.js";var r=e((async function(e){let r,m;"string"==typeof e?r=e:e&&(m=e.locale,r=e.namespace);const c=await t(m||await o());return a({...c,messageFormatCache:s(),namespace:r,messages:c.messages})}));export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const L="NEXT_LOCALE",
|
|
1
|
+
const L="NEXT_LOCALE",E=31536e3,e="lax",l="X-NEXT-INTL-LOCALE",o="locale";export{L as COOKIE_LOCALE_NAME,E as COOKIE_MAX_AGE,e as COOKIE_SAME_SITE,l as HEADER_LOCALE_NAME,o as LOCALE_SEGMENT_NAME};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cache as r}from"react";const t=r((function(){return new Map}));export{t as getMessageFormatCache};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),a=require("../shared/messageFormatCache.js");var t=e.cache((function(e,t){return r.createTranslator({...e,messageFormatCache:a.getMessageFormatCache(),namespace:t})}));exports.default=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("use-intl/core"),r=require("./getConfig.js"),t=require("./getLocale.js");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("use-intl/core"),r=require("../../shared/messageFormatCache.js"),s=require("./getConfig.js"),t=require("./getLocale.js");var c=e.cache((async function(e){let c,o;"string"==typeof e?c=e:e&&(o=e.locale,c=e.namespace);const u=await s.default(o||await t.default());return a.createTranslator({...u,messageFormatCache:r.getMessageFormatCache(),namespace:c,messages:u.messages})}));exports.default=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.COOKIE_LOCALE_NAME="NEXT_LOCALE",exports.COOKIE_MAX_AGE=31536e3,exports.COOKIE_SAME_SITE="
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.COOKIE_LOCALE_NAME="NEXT_LOCALE",exports.COOKIE_MAX_AGE=31536e3,exports.COOKIE_SAME_SITE="lax",exports.HEADER_LOCALE_NAME="X-NEXT-INTL-LOCALE",exports.LOCALE_SEGMENT_NAME="locale";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("react").cache((function(){return new Map}));exports.getMessageFormatCache=e;
|
|
@@ -3,7 +3,7 @@ export { default } from 'react';
|
|
|
3
3
|
export declare function use(promise: Promise<unknown> & {
|
|
4
4
|
value?: unknown;
|
|
5
5
|
}): {};
|
|
6
|
-
export declare function cache(fn: (...args: Array<unknown>) => unknown): (...args: Array<unknown>) =>
|
|
6
|
+
export declare function cache(fn: (...args: Array<unknown>) => unknown): (...args: Array<unknown>) => any;
|
|
7
7
|
export declare namespace cache {
|
|
8
8
|
var reset: () => void;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const COOKIE_LOCALE_NAME = "NEXT_LOCALE";
|
|
2
2
|
export declare const COOKIE_MAX_AGE = 31536000;
|
|
3
|
-
export declare const COOKIE_SAME_SITE = "
|
|
3
|
+
export declare const COOKIE_SAME_SITE = "lax";
|
|
4
4
|
export declare const COOKIE_BASE_PATH_NAME = "NEXT_INTL_BASE_PATH";
|
|
5
5
|
export declare const HEADER_LOCALE_NAME = "X-NEXT-INTL-LOCALE";
|
|
6
6
|
export declare const LOCALE_SEGMENT_NAME = "locale";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
84
84
|
"negotiator": "^0.6.3",
|
|
85
|
-
"use-intl": "^3.5.
|
|
85
|
+
"use-intl": "^3.5.3"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"limit": "5.81 KB"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "899552bf5629b29db88353fbc58a8397c086b285"
|
|
145
145
|
}
|