next-intl 3.12.0-provided-locale.1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/middleware/utils.js +52 -1
- package/dist/development/react-server/useConfig.js +3 -1
- package/dist/development/react-server/useLocale.js +2 -3
- package/dist/development/server/react-server/getConfig.js +14 -18
- package/dist/development/server/react-server/getFormatter.js +3 -1
- package/dist/development/server/react-server/getLocale.js +3 -7
- package/dist/development/server/react-server/getMessages.js +3 -1
- package/dist/development/server/react-server/getNow.js +3 -1
- package/dist/development/server/react-server/getTimeZone.js +3 -1
- package/dist/development/server/react-server/getTranslations.js +2 -1
- package/dist/development/server/react-server/resolveLocaleArg.js +15 -0
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/react-server/useConfig.js +1 -1
- package/dist/esm/react-server/useLocale.js +1 -1
- package/dist/esm/server/react-server/getConfig.js +1 -1
- package/dist/esm/server/react-server/getFormatter.js +1 -1
- package/dist/esm/server/react-server/getLocale.js +1 -1
- package/dist/esm/server/react-server/getMessages.js +1 -1
- package/dist/esm/server/react-server/getNow.js +1 -1
- package/dist/esm/server/react-server/getTimeZone.js +1 -1
- package/dist/esm/server/react-server/getTranslations.js +1 -1
- package/dist/esm/server/react-server/resolveLocaleArg.js +1 -0
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/react-server/useConfig.js +1 -1
- package/dist/production/react-server/useLocale.js +1 -1
- package/dist/production/server/react-server/getConfig.js +1 -1
- package/dist/production/server/react-server/getFormatter.js +1 -1
- package/dist/production/server/react-server/getLocale.js +1 -1
- package/dist/production/server/react-server/getMessages.js +1 -1
- package/dist/production/server/react-server/getNow.js +1 -1
- package/dist/production/server/react-server/getTimeZone.js +1 -1
- package/dist/production/server/react-server/getTranslations.js +1 -1
- package/dist/production/server/react-server/resolveLocaleArg.js +1 -0
- package/dist/types/src/middleware/utils.d.ts +2 -0
- package/dist/types/src/server/react-client/index.d.ts +2 -2
- package/dist/types/src/server/react-server/getConfig.d.ts +1 -1
- package/dist/types/src/server/react-server/getLocale.d.ts +1 -3
- package/dist/types/src/server/react-server/resolveLocaleArg.d.ts +3 -0
- package/package.json +17 -14
|
@@ -7,9 +7,58 @@ var utils = require('../shared/utils.js');
|
|
|
7
7
|
function getFirstPathnameSegment(pathname) {
|
|
8
8
|
return pathname.split('/')[1];
|
|
9
9
|
}
|
|
10
|
+
function isOptionalCatchAllSegment(pathname) {
|
|
11
|
+
return pathname.includes('[[...');
|
|
12
|
+
}
|
|
13
|
+
function isCatchAllSegment(pathname) {
|
|
14
|
+
return pathname.includes('[...');
|
|
15
|
+
}
|
|
16
|
+
function isDynamicSegment(pathname) {
|
|
17
|
+
return pathname.includes('[');
|
|
18
|
+
}
|
|
19
|
+
function comparePathnamePairs(a, b) {
|
|
20
|
+
const pathA = a.split('/');
|
|
21
|
+
const pathB = b.split('/');
|
|
22
|
+
const maxLength = Math.max(pathA.length, pathB.length);
|
|
23
|
+
for (let i = 0; i < maxLength; i++) {
|
|
24
|
+
const segmentA = pathA[i];
|
|
25
|
+
const segmentB = pathB[i];
|
|
26
|
+
|
|
27
|
+
// If one of the paths ends, prioritize the shorter path
|
|
28
|
+
if (!segmentA && segmentB) return -1;
|
|
29
|
+
if (segmentA && !segmentB) return 1;
|
|
30
|
+
|
|
31
|
+
// Prioritize static segments over dynamic segments
|
|
32
|
+
if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
|
|
33
|
+
if (isDynamicSegment(segmentA) && !isDynamicSegment(segmentB)) return 1;
|
|
34
|
+
|
|
35
|
+
// Prioritize non-catch-all segments over catch-all segments
|
|
36
|
+
if (!isCatchAllSegment(segmentA) && isCatchAllSegment(segmentB)) return -1;
|
|
37
|
+
if (isCatchAllSegment(segmentA) && !isCatchAllSegment(segmentB)) return 1;
|
|
38
|
+
|
|
39
|
+
// Prioritize non-optional catch-all segments over optional catch-all segments
|
|
40
|
+
if (!isOptionalCatchAllSegment(segmentA) && isOptionalCatchAllSegment(segmentB)) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
if (isOptionalCatchAllSegment(segmentA) && !isOptionalCatchAllSegment(segmentB)) {
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
if (segmentA === segmentB) continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Both pathnames are completely static
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
function getSortedPathnames(pathnames) {
|
|
53
|
+
const sortedPathnames = pathnames.sort(comparePathnamePairs);
|
|
54
|
+
return sortedPathnames;
|
|
55
|
+
}
|
|
10
56
|
function getInternalTemplate(pathnames, pathname, locale) {
|
|
57
|
+
const sortedPathnames = getSortedPathnames(Object.keys(pathnames));
|
|
58
|
+
|
|
11
59
|
// Try to find a localized pathname that matches
|
|
12
|
-
for (const
|
|
60
|
+
for (const internalPathname of sortedPathnames) {
|
|
61
|
+
const localizedPathnamesOrPathname = pathnames[internalPathname];
|
|
13
62
|
if (typeof localizedPathnamesOrPathname === 'string') {
|
|
14
63
|
const localizedPathname = localizedPathnamesOrPathname;
|
|
15
64
|
if (utils.matchesPathname(localizedPathname, pathname)) {
|
|
@@ -159,6 +208,7 @@ function normalizeTrailingSlash(pathname) {
|
|
|
159
208
|
}
|
|
160
209
|
|
|
161
210
|
exports.applyBasePath = applyBasePath;
|
|
211
|
+
exports.comparePathnamePairs = comparePathnamePairs;
|
|
162
212
|
exports.findCaseInsensitiveLocale = findCaseInsensitiveLocale;
|
|
163
213
|
exports.formatPathname = formatPathname;
|
|
164
214
|
exports.formatTemplatePathname = formatTemplatePathname;
|
|
@@ -170,4 +220,5 @@ exports.getNormalizedPathname = getNormalizedPathname;
|
|
|
170
220
|
exports.getPathWithSearch = getPathWithSearch;
|
|
171
221
|
exports.getPathnameLocale = getPathnameLocale;
|
|
172
222
|
exports.getRouteParams = getRouteParams;
|
|
223
|
+
exports.getSortedPathnames = getSortedPathnames;
|
|
173
224
|
exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var getConfig = require('../server/react-server/getConfig.js');
|
|
7
|
+
var useLocale = require('./useLocale.js');
|
|
7
8
|
|
|
8
9
|
function useHook(hookName, promise) {
|
|
9
10
|
try {
|
|
@@ -19,7 +20,8 @@ function useHook(hookName, promise) {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
function useConfig(hookName) {
|
|
22
|
-
|
|
23
|
+
const locale = useLocale.default();
|
|
24
|
+
return useHook(hookName, getConfig.default(locale));
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
exports.default = useConfig;
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var RequestLocale = require('../server/react-server/RequestLocale.js');
|
|
6
6
|
|
|
7
7
|
function useLocale() {
|
|
8
8
|
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
9
|
_ref[_key] = arguments[_key];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
return config.locale;
|
|
11
|
+
return RequestLocale.getRequestLocale();
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
exports.default = useLocale;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var core = require('use-intl/core');
|
|
7
|
-
var RequestLocale = require('./RequestLocale.js');
|
|
8
7
|
var getRuntimeConfig = require('next-intl/config');
|
|
9
8
|
|
|
10
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -23,31 +22,28 @@ function getDefaultTimeZoneImpl() {
|
|
|
23
22
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
24
23
|
}
|
|
25
24
|
const getDefaultTimeZone = React.cache(getDefaultTimeZoneImpl);
|
|
26
|
-
async function receiveRuntimeConfigImpl(
|
|
27
|
-
var _result, _result2
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const params = {
|
|
32
|
-
get locale() {
|
|
33
|
-
return localeOverride || RequestLocale.getRequestLocale();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
let result = getConfig === null || getConfig === void 0 ? void 0 : getConfig(params);
|
|
25
|
+
async function receiveRuntimeConfigImpl(locale, getConfig) {
|
|
26
|
+
var _result, _result2;
|
|
27
|
+
let result = getConfig === null || getConfig === void 0 ? void 0 : getConfig({
|
|
28
|
+
locale
|
|
29
|
+
});
|
|
37
30
|
if (result instanceof Promise) {
|
|
38
31
|
result = await result;
|
|
39
32
|
}
|
|
40
33
|
return {
|
|
41
34
|
...result,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
timeZone: ((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.timeZone) || getDefaultTimeZone()
|
|
35
|
+
now: ((_result = result) === null || _result === void 0 ? void 0 : _result.now) || getDefaultNow(),
|
|
36
|
+
timeZone: ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.timeZone) || getDefaultTimeZone()
|
|
45
37
|
};
|
|
46
38
|
}
|
|
47
39
|
const receiveRuntimeConfig = React.cache(receiveRuntimeConfigImpl);
|
|
48
|
-
async function getConfigImpl(
|
|
49
|
-
const runtimeConfig = await receiveRuntimeConfig(
|
|
50
|
-
|
|
40
|
+
async function getConfigImpl(locale) {
|
|
41
|
+
const runtimeConfig = await receiveRuntimeConfig(locale, getRuntimeConfig__default.default);
|
|
42
|
+
const opts = {
|
|
43
|
+
...runtimeConfig,
|
|
44
|
+
locale
|
|
45
|
+
};
|
|
46
|
+
return core.initializeConfig(opts);
|
|
51
47
|
}
|
|
52
48
|
const getConfig = React.cache(getConfigImpl);
|
|
53
49
|
var getConfig$1 = getConfig;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var core = require('use-intl/core');
|
|
7
7
|
var getConfig = require('./getConfig.js');
|
|
8
|
+
var resolveLocaleArg = require('./resolveLocaleArg.js');
|
|
8
9
|
|
|
9
10
|
async function getFormatterCachedImpl(locale) {
|
|
10
11
|
const config = await getConfig.default(locale);
|
|
@@ -19,7 +20,8 @@ const getFormatterCached = React.cache(getFormatterCachedImpl);
|
|
|
19
20
|
* you can override it by passing in additional options.
|
|
20
21
|
*/
|
|
21
22
|
async function getFormatter(opts) {
|
|
22
|
-
|
|
23
|
+
const locale = await resolveLocaleArg.default(opts);
|
|
24
|
+
return getFormatterCached(locale);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
exports.default = getFormatter;
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var getConfig = require('./getConfig.js');
|
|
5
|
+
var RequestLocale = require('./RequestLocale.js');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return Promise.resolve(config.locale);
|
|
7
|
+
function getLocale() {
|
|
8
|
+
return Promise.resolve(RequestLocale.getRequestLocale());
|
|
11
9
|
}
|
|
12
|
-
const getLocaleCached = React.cache(getLocaleCachedImpl);
|
|
13
|
-
var getLocale = getLocaleCached;
|
|
14
10
|
|
|
15
11
|
exports.default = getLocale;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var getConfig = require('./getConfig.js');
|
|
7
|
+
var resolveLocaleArg = require('./resolveLocaleArg.js');
|
|
7
8
|
|
|
8
9
|
function getMessagesFromConfig(config) {
|
|
9
10
|
if (!config.messages) {
|
|
@@ -17,7 +18,8 @@ async function getMessagesCachedImpl(locale) {
|
|
|
17
18
|
}
|
|
18
19
|
const getMessagesCached = React.cache(getMessagesCachedImpl);
|
|
19
20
|
async function getMessages(opts) {
|
|
20
|
-
|
|
21
|
+
const locale = await resolveLocaleArg.default(opts);
|
|
22
|
+
return getMessagesCached(locale);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
exports.default = getMessages;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var getConfig = require('./getConfig.js');
|
|
7
|
+
var resolveLocaleArg = require('./resolveLocaleArg.js');
|
|
7
8
|
|
|
8
9
|
async function getNowCachedImpl(locale) {
|
|
9
10
|
const config = await getConfig.default(locale);
|
|
@@ -11,7 +12,8 @@ async function getNowCachedImpl(locale) {
|
|
|
11
12
|
}
|
|
12
13
|
const getNowCached = React.cache(getNowCachedImpl);
|
|
13
14
|
async function getNow(opts) {
|
|
14
|
-
|
|
15
|
+
const locale = await resolveLocaleArg.default(opts);
|
|
16
|
+
return getNowCached(locale);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
exports.default = getNow;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var getConfig = require('./getConfig.js');
|
|
7
|
+
var resolveLocaleArg = require('./resolveLocaleArg.js');
|
|
7
8
|
|
|
8
9
|
async function getTimeZoneCachedImpl(locale) {
|
|
9
10
|
const config = await getConfig.default(locale);
|
|
@@ -11,7 +12,8 @@ async function getTimeZoneCachedImpl(locale) {
|
|
|
11
12
|
}
|
|
12
13
|
const getTimeZoneCached = React.cache(getTimeZoneCachedImpl);
|
|
13
14
|
async function getTimeZone(opts) {
|
|
14
|
-
|
|
15
|
+
const locale = await resolveLocaleArg.default(opts);
|
|
16
|
+
return getTimeZoneCached(locale);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
exports.default = getTimeZone;
|
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var core = require('use-intl/core');
|
|
7
7
|
var messageFormatCache = require('../../shared/messageFormatCache.js');
|
|
8
8
|
var getConfig = require('./getConfig.js');
|
|
9
|
+
var getLocale = require('./getLocale.js');
|
|
9
10
|
|
|
10
11
|
// Maintainer note: `getTranslations` has two different call signatures.
|
|
11
12
|
// We need to define these with function overloads, otherwise TypeScript
|
|
@@ -23,7 +24,7 @@ async function getTranslations(namespaceOrOpts) {
|
|
|
23
24
|
locale = namespaceOrOpts.locale;
|
|
24
25
|
namespace = namespaceOrOpts.namespace;
|
|
25
26
|
}
|
|
26
|
-
const config = await getConfig.default(locale);
|
|
27
|
+
const config = await getConfig.default(locale || (await getLocale.default()));
|
|
27
28
|
return core.createTranslator({
|
|
28
29
|
...config,
|
|
29
30
|
messageFormatCache: messageFormatCache.getMessageFormatCache(),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var getLocale = require('./getLocale.js');
|
|
6
|
+
|
|
7
|
+
function resolveLocaleArg(opts) {
|
|
8
|
+
if (opts !== null && opts !== void 0 && opts.locale) {
|
|
9
|
+
return Promise.resolve(opts.locale);
|
|
10
|
+
} else {
|
|
11
|
+
return getLocale.default();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.default = resolveLocaleArg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesPathname as n,templateToRegex as t}from"../shared/utils.js";function e(n){return n.split("/")[1]}function o(t,e,
|
|
1
|
+
import{matchesPathname as n,templateToRegex as t}from"../shared/utils.js";function e(n){return n.split("/")[1]}function r(n){return n.includes("[[...")}function o(n){return n.includes("[...")}function i(n){return n.includes("[")}function u(n,t){const e=n.split("/"),u=t.split("/"),c=Math.max(e.length,u.length);for(let n=0;n<c;n++){const t=e[n],c=u[n];if(!t&&c)return-1;if(t&&!c)return 1;if(!i(t)&&i(c))return-1;if(i(t)&&!i(c))return 1;if(!o(t)&&o(c))return-1;if(o(t)&&!o(c))return 1;if(!r(t)&&r(c))return-1;if(r(t)&&!r(c))return 1}return 0}function c(n){return n.sort(u)}function l(t,e,r){const o=c(Object.keys(t));for(const i of o){const o=t[i];if("string"==typeof o){if(n(o,e))return[void 0,i]}else{const t=Object.entries(o),u=t.findIndex((n=>{let[t]=n;return t===r}));u>0&&t.unshift(t.splice(u,1)[0]);for(const[r,o]of t)if(n(o,e))return[r,i]}}for(const r of Object.keys(t))if(n(r,e))return[void 0,r];return[void 0,void 0]}function f(n,t,e,r){const o=h(t,n);let i="";return r&&(i="/".concat(r)),i+=v(e,o),i=b(i),i}function s(n,t){n.endsWith("/")||(n+="/");const e=n.match(new RegExp("^/(".concat(t.join("|"),")/(.*)"),"i"));let r=e?"/"+e[2]:n;return"/"!==r&&(r=b(r)),r}function d(n,t){return t.find((t=>t.toLowerCase()===n.toLowerCase()))}function a(n,t){const r=e(n);return d(r,t)?r:void 0}function h(n,e){const r=t(n).exec(e);if(!r)return;const o={};for(let t=1;t<r.length;t++){var i;const e=null===(i=n.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[t-1].replace(/[[\]]/g,"");e&&(o[e]=r[t])}return o}function v(n,t){if(!t)return n;let e=n=n.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((n=>{let[t,r]=n;e=e.replace("[".concat(t,"]"),r)})),e}function p(n,t){let e=n;return t&&(e+=t),e}function g(n){var t,e;return null!==(t=null!==(e=n.get("x-forwarded-host"))&&void 0!==e?e:n.get("host"))&&void 0!==t?t:void 0}function j(n,t){return t.defaultLocale===n||!t.locales||t.locales.includes(n)}function x(n,t,e){let r;return n&&j(t,n)&&(r=n),r||(r=e.find((n=>n.defaultLocale===t))),r||(r=e.find((n=>null!=n.locales&&n.locales.includes(t)))),r||null!=(null==n?void 0:n.locales)||(r=n),r||(r=e.find((n=>!n.locales))),r}function m(n,t){return b(t+n)}function b(n){return n.endsWith("/")&&(n=n.slice(0,-1)),n}export{m as applyBasePath,u as comparePathnamePairs,d as findCaseInsensitiveLocale,v as formatPathname,f as formatTemplatePathname,x as getBestMatchingDomain,e as getFirstPathnameSegment,g as getHost,l as getInternalTemplate,s as getNormalizedPathname,p as getPathWithSearch,a as getPathnameLocale,h as getRouteParams,c as getSortedPathnames,j as isLocaleSupportedOnDomain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{use as e}from"react";import
|
|
1
|
+
import{use as e}from"react";import r from"../server/react-server/getConfig.js";import n from"./useLocale.js";function t(t){const o=n();return function(r,n){try{return e(n)}catch(e){throw e instanceof TypeError&&e.message.includes("Cannot read properties of null (reading 'use')")?new Error("`".concat(r,"` is not callable within an async component. Please refer to https://next-intl-docs.vercel.app/docs/environments/server-client-components#async-components"),{cause:e}):e}}(t,r(o))}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{getRequestLocale as r}from"../server/react-server/RequestLocale.js";function e(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r()}export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as
|
|
1
|
+
import{cache as n}from"react";import{initializeConfig as o}from"use-intl/core";import t from"next-intl/config";const e=n((function(){return new Date}));const i=n((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const r=n((async function(n,o){var t,r;let a=null==o?void 0:o({locale:n});return a instanceof Promise&&(a=await a),{...a,now:(null===(t=a)||void 0===t?void 0:t.now)||e(),timeZone:(null===(r=a)||void 0===r?void 0:r.timeZone)||i()}}));var a=n((async function(n){const e={...await r(n,t),locale:n};return o(e)}));export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as o}from"react";import{createFormatter as t}from"use-intl/core";import
|
|
1
|
+
import{cache as o}from"react";import{createFormatter as t}from"use-intl/core";import r from"./getConfig.js";import n from"./resolveLocaleArg.js";const e=o((async function(o){const n=await r(o);return t(n)}));async function a(o){const t=await n(o);return e(t)}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getRequestLocale as e}from"./RequestLocale.js";function o(){return Promise.resolve(e())}export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import o from"./getConfig.js";function t(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return e.messages}const
|
|
1
|
+
import{cache as e}from"react";import o from"./getConfig.js";import r from"./resolveLocaleArg.js";function t(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return e.messages}const s=e((async function(e){return t(await o(e))}));async function n(e){const o=await r(e);return s(o)}export{n as default,t as getMessagesFromConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as
|
|
1
|
+
import{cache as o}from"react";import t from"./getConfig.js";import r from"./resolveLocaleArg.js";const n=o((async function(o){return(await t(o)).now}));async function a(o){const t=await r(o);return n(t)}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as t}from"react";import
|
|
1
|
+
import{cache as t}from"react";import o from"./getConfig.js";import r from"./resolveLocaleArg.js";const n=t((async function(t){return(await o(t)).timeZone}));async function e(t){const o=await r(t);return n(o)}export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import{createTranslator as a}from"use-intl/core";import{getMessageFormatCache as s}from"../../shared/messageFormatCache.js";import
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./getLocale.js";function l(l){return null!=l&&l.locale?Promise.resolve(l.locale):e()}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(e,t){return t.find((t=>t.toLowerCase()===e.toLowerCase()))}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(e){return e.includes("[[...")}function r(e){return e.includes("[...")}function o(e){return e.includes("[")}function i(e,t){const i=e.split("/"),s=t.split("/"),c=Math.max(i.length,s.length);for(let e=0;e<c;e++){const t=i[e],c=s[e];if(!t&&c)return-1;if(t&&!c)return 1;if(!o(t)&&o(c))return-1;if(o(t)&&!o(c))return 1;if(!r(t)&&r(c))return-1;if(r(t)&&!r(c))return 1;if(!n(t)&&n(c))return-1;if(n(t)&&!n(c))return 1}return 0}function s(e){return e.sort(i)}function c(e,t){return t.find((t=>t.toLowerCase()===e.toLowerCase()))}function a(t,n){const r=e.templateToRegex(t).exec(n);if(!r)return;const o={};for(let e=1;e<r.length;e++){var i;const n=null===(i=t.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");n&&(o[n]=r[e])}return o}function u(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function l(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function f(e){return e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return f(t+e)},exports.comparePathnamePairs=i,exports.findCaseInsensitiveLocale=c,exports.formatPathname=u,exports.formatTemplatePathname=function(e,t,n,r){const o=a(t,e);let i="";return r&&(i="/".concat(r)),i+=u(n,o),i=f(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&l(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getFirstPathnameSegment=t,exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=s(Object.keys(t));for(const i of o){const o=t[i];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,i]}else{const t=Object.entries(o),s=t.findIndex((e=>{let[t]=e;return t===r}));s>0&&t.unshift(t.splice(s,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,i]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getNormalizedPathname=function(e,t){e.endsWith("/")||(e+="/");const n=e.match(new RegExp("^/(".concat(t.join("|"),")/(.*)"),"i"));let r=n?"/"+n[2]:e;return"/"!==r&&(r=f(r)),r},exports.getPathWithSearch=function(e,t){let n=e;return t&&(n+=t),n},exports.getPathnameLocale=function(e,n){const r=t(e);return c(r,n)?r:void 0},exports.getRouteParams=a,exports.getSortedPathnames=s,exports.isLocaleSupportedOnDomain=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../server/react-server/getConfig.js");exports.default=function(n){return function(r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../server/react-server/getConfig.js"),t=require("./useLocale.js");exports.default=function(n){const s=t.default();return function(r,t){try{return e.use(t)}catch(e){throw e instanceof TypeError&&e.message.includes("Cannot read properties of null (reading 'use')")?new Error("`".concat(r,"` is not callable within an async component. Please refer to https://next-intl-docs.vercel.app/docs/environments/server-client-components#async-components"),{cause:e}):e}}(n,r.default(s))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../server/react-server/RequestLocale.js");exports.default=function(){for(var r=arguments.length,t=new Array(r),s=0;s<r;s++)t[s]=arguments[s];return e.getRequestLocale()};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("use-intl/core");function t(e){return e&&e.__esModule?e:{default:e}}var o=t(require("next-intl/config"));const i=e.cache((function(){return new Date}));const r=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const c=e.cache((async function(e,n){var t,o;let c=null==n?void 0:n({locale:e});return c instanceof Promise&&(c=await c),{...c,now:(null===(t=c)||void 0===t?void 0:t.now)||i(),timeZone:(null===(o=c)||void 0===o?void 0:o.timeZone)||r()}}));var a=e.cache((async function(e){const t={...await c(e,o.default),locale:e};return n.initializeConfig(t)}));exports.default=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),t=require("./getConfig.js");const c=e.cache((async function(e){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),t=require("./getConfig.js"),a=require("./resolveLocaleArg.js");const c=e.cache((async function(e){const a=await t.default(e);return r.createFormatter(a)}));exports.default=async function(e){const r=await a.default(e);return c(r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./RequestLocale.js");exports.default=function(){return Promise.resolve(e.getRequestLocale())};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./getConfig.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./getConfig.js"),s=require("./resolveLocaleArg.js");function t(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return e.messages}const o=e.cache((async function(e){return t(await r.default(e))}));exports.default=async function(e){const r=await s.default(e);return o(r)},exports.getMessagesFromConfig=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./getConfig.js"),t=require("./resolveLocaleArg.js");const a=e.cache((async function(e){return(await r.default(e)).now}));exports.default=async function(e){const r=await t.default(e);return a(r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./getConfig.js");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./getConfig.js"),r=require("./resolveLocaleArg.js");const a=e.cache((async function(e){return(await t.default(e)).timeZone}));exports.default=async function(e){const t=await r.default(e);return a(t)};
|
|
@@ -1 +1 @@
|
|
|
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");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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./getLocale.js");exports.default=function(l){return null!=l&&l.locale?Promise.resolve(l.locale):e.default()};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AllLocales } from '../shared/types';
|
|
2
2
|
import { DomainConfig, MiddlewareConfigWithDefaults } from './NextIntlMiddlewareConfig';
|
|
3
3
|
export declare function getFirstPathnameSegment(pathname: string): string;
|
|
4
|
+
export declare function comparePathnamePairs(a: string, b: string): number;
|
|
5
|
+
export declare function getSortedPathnames(pathnames: Array<string>): string[];
|
|
4
6
|
export declare function getInternalTemplate<Locales extends AllLocales, Pathnames extends NonNullable<MiddlewareConfigWithDefaults<Locales>['pathnames']>>(pathnames: Pathnames, pathname: string, locale: Locales[number]): [Locales[number] | undefined, keyof Pathnames | undefined];
|
|
5
7
|
export declare function formatTemplatePathname(sourcePathname: string, sourceTemplate: string, targetTemplate: string, localePrefix?: string): string;
|
|
6
8
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { getRequestConfig as getRequestConfig_type, getFormatter as getFormatter_type, getNow as getNow_type, getTimeZone as getTimeZone_type, getMessages as getMessages_type, unstable_setRequestLocale as unstable_setRequestLocale_type } from '../react-server';
|
|
1
|
+
import type { getRequestConfig as getRequestConfig_type, getFormatter as getFormatter_type, getNow as getNow_type, getTimeZone as getTimeZone_type, getMessages as getMessages_type, getLocale as getLocale_type, unstable_setRequestLocale as unstable_setRequestLocale_type } from '../react-server';
|
|
2
2
|
export declare function getRequestConfig(...args: Parameters<typeof getRequestConfig_type>): ReturnType<typeof getRequestConfig_type>;
|
|
3
3
|
export declare const getFormatter: typeof getFormatter_type;
|
|
4
4
|
export declare const getNow: typeof getNow_type;
|
|
5
5
|
export declare const getTimeZone: typeof getTimeZone_type;
|
|
6
6
|
export declare const getMessages: typeof getMessages_type;
|
|
7
|
-
export declare const getLocale:
|
|
7
|
+
export declare const getLocale: typeof getLocale_type;
|
|
8
8
|
export declare const getTranslations: () => never;
|
|
9
9
|
export declare const unstable_setRequestLocale: typeof unstable_setRequestLocale_type;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntlConfig } from 'use-intl/core';
|
|
2
|
-
declare function getConfigImpl(
|
|
2
|
+
declare function getConfigImpl(locale: string): Promise<IntlConfig & {
|
|
3
3
|
getMessageFallback: NonNullable<IntlConfig['getMessageFallback']>;
|
|
4
4
|
now: NonNullable<IntlConfig['now']>;
|
|
5
5
|
onError: NonNullable<IntlConfig['onError']>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.12.0
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -16,6 +16,16 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/amannn/next-intl"
|
|
18
18
|
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rm -rf dist && rollup -c",
|
|
21
|
+
"test": "TZ=Europe/Berlin vitest",
|
|
22
|
+
"lint": "pnpm run lint:source && pnpm run lint:package",
|
|
23
|
+
"lint:source": "eslint src test && tsc --noEmit",
|
|
24
|
+
"lint:package": "publint && attw --pack",
|
|
25
|
+
"prepublishOnly": "CI=true turbo test && turbo lint && turbo build && cp ../../README.md .",
|
|
26
|
+
"postpublish": "git checkout . && rm ./README.md",
|
|
27
|
+
"size": "size-limit"
|
|
28
|
+
},
|
|
19
29
|
"main": "./dist/index.react-client.js",
|
|
20
30
|
"module": "./dist/esm/index.react-client.js",
|
|
21
31
|
"typings": "./dist/types/src/index.react-client.d.ts",
|
|
@@ -72,7 +82,7 @@
|
|
|
72
82
|
"dependencies": {
|
|
73
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
74
84
|
"negotiator": "^0.6.3",
|
|
75
|
-
"use-intl": "^3.
|
|
85
|
+
"use-intl": "^3.12.0"
|
|
76
86
|
},
|
|
77
87
|
"peerDependencies": {
|
|
78
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -108,7 +118,7 @@
|
|
|
108
118
|
},
|
|
109
119
|
{
|
|
110
120
|
"path": "dist/production/index.react-server.js",
|
|
111
|
-
"limit": "13.
|
|
121
|
+
"limit": "13.765 KB"
|
|
112
122
|
},
|
|
113
123
|
{
|
|
114
124
|
"path": "dist/production/navigation.react-client.js",
|
|
@@ -116,7 +126,7 @@
|
|
|
116
126
|
},
|
|
117
127
|
{
|
|
118
128
|
"path": "dist/production/navigation.react-server.js",
|
|
119
|
-
"limit": "
|
|
129
|
+
"limit": "3.06 KB"
|
|
120
130
|
},
|
|
121
131
|
{
|
|
122
132
|
"path": "dist/production/server.react-client.js",
|
|
@@ -128,15 +138,8 @@
|
|
|
128
138
|
},
|
|
129
139
|
{
|
|
130
140
|
"path": "dist/production/middleware.js",
|
|
131
|
-
"limit": "6 KB"
|
|
141
|
+
"limit": "6.19 KB"
|
|
132
142
|
}
|
|
133
143
|
],
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
"test": "TZ=Europe/Berlin vitest",
|
|
137
|
-
"lint": "pnpm run lint:source && pnpm run lint:package",
|
|
138
|
-
"lint:source": "eslint src test && tsc --noEmit",
|
|
139
|
-
"lint:package": "publint && attw --pack",
|
|
140
|
-
"size": "size-limit"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
144
|
+
"gitHead": "0bb5827ae29f3644100d1685ce9b10beeeb4acd5"
|
|
145
|
+
}
|