next-intl 3.11.2 → 3.12.0-provided-locale.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.
- package/dist/development/middleware/resolveLocale.js +60 -27
- package/dist/development/react-server/useConfig.js +1 -3
- package/dist/development/react-server/useLocale.js +3 -2
- package/dist/development/server/react-server/getConfig.js +18 -14
- package/dist/development/server/react-server/getFormatter.js +1 -3
- package/dist/development/server/react-server/getLocale.js +7 -3
- package/dist/development/server/react-server/getMessages.js +1 -3
- package/dist/development/server/react-server/getNow.js +1 -3
- package/dist/development/server/react-server/getTimeZone.js +1 -3
- package/dist/development/server/react-server/getTranslations.js +1 -2
- package/dist/esm/middleware/resolveLocale.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/production/middleware/resolveLocale.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/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 +3 -1
- package/package.json +15 -18
- package/dist/development/server/react-server/resolveLocaleArg.js +0 -15
- package/dist/esm/server/react-server/resolveLocaleArg.js +0 -1
- package/dist/production/server/react-server/resolveLocaleArg.js +0 -1
- package/dist/types/src/server/react-server/resolveLocaleArg.d.ts +0 -3
|
@@ -36,6 +36,19 @@ function getAcceptLanguageLocale(requestHeaders, locales, defaultLocale) {
|
|
|
36
36
|
}
|
|
37
37
|
return locale;
|
|
38
38
|
}
|
|
39
|
+
function getLocaleFromPrefix(pathname, locales) {
|
|
40
|
+
const pathLocaleCandidate = utils.getFirstPathnameSegment(pathname);
|
|
41
|
+
return utils.findCaseInsensitiveLocale(pathLocaleCandidate, locales);
|
|
42
|
+
}
|
|
43
|
+
function getLocaleFromCookie(requestCookies, locales) {
|
|
44
|
+
if (requestCookies.has(constants.COOKIE_LOCALE_NAME)) {
|
|
45
|
+
var _requestCookies$get;
|
|
46
|
+
const value = (_requestCookies$get = requestCookies.get(constants.COOKIE_LOCALE_NAME)) === null || _requestCookies$get === void 0 ? void 0 : _requestCookies$get.value;
|
|
47
|
+
if (value && locales.includes(value)) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
function resolveLocaleFromPrefix(_ref, requestHeaders, requestCookies, pathname) {
|
|
40
53
|
let {
|
|
41
54
|
defaultLocale,
|
|
@@ -46,22 +59,12 @@ function resolveLocaleFromPrefix(_ref, requestHeaders, requestCookies, pathname)
|
|
|
46
59
|
|
|
47
60
|
// Prio 1: Use route prefix
|
|
48
61
|
if (pathname) {
|
|
49
|
-
|
|
50
|
-
const matchedLocale = utils.findCaseInsensitiveLocale(pathLocaleCandidate, locales);
|
|
51
|
-
if (matchedLocale) {
|
|
52
|
-
locale = matchedLocale;
|
|
53
|
-
}
|
|
62
|
+
locale = getLocaleFromPrefix(pathname, locales);
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
// Prio 2: Use existing cookie
|
|
57
66
|
if (!locale && localeDetection && requestCookies) {
|
|
58
|
-
|
|
59
|
-
var _requestCookies$get;
|
|
60
|
-
const value = (_requestCookies$get = requestCookies.get(constants.COOKIE_LOCALE_NAME)) === null || _requestCookies$get === void 0 ? void 0 : _requestCookies$get.value;
|
|
61
|
-
if (value && locales.includes(value)) {
|
|
62
|
-
locale = value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
67
|
+
locale = getLocaleFromCookie(requestCookies, locales);
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
// Prio 3: Use the `accept-language` header
|
|
@@ -76,26 +79,56 @@ function resolveLocaleFromPrefix(_ref, requestHeaders, requestCookies, pathname)
|
|
|
76
79
|
return locale;
|
|
77
80
|
}
|
|
78
81
|
function resolveLocaleFromDomain(config, requestHeaders, requestCookies, pathname) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const domains = config.domains;
|
|
83
|
+
const domain = findDomainFromHost(requestHeaders, domains);
|
|
84
|
+
if (!domain) {
|
|
85
|
+
return {
|
|
86
|
+
locale: resolveLocaleFromPrefix(config, requestHeaders, requestCookies, pathname)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
let locale;
|
|
83
90
|
|
|
84
|
-
// Prio 1: Use
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
domain
|
|
92
|
-
|
|
91
|
+
// Prio 1: Use route prefix
|
|
92
|
+
if (pathname) {
|
|
93
|
+
const prefixLocale = getLocaleFromPrefix(pathname, config.locales);
|
|
94
|
+
if (prefixLocale) {
|
|
95
|
+
if (utils.isLocaleSupportedOnDomain(prefixLocale, domain)) {
|
|
96
|
+
locale = prefixLocale;
|
|
97
|
+
} else {
|
|
98
|
+
// Causes a redirect to a domain that supports the locale
|
|
99
|
+
return {
|
|
100
|
+
locale: prefixLocale,
|
|
101
|
+
domain
|
|
102
|
+
};
|
|
103
|
+
}
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
// Prio 2: Use
|
|
107
|
+
// Prio 2: Use existing cookie
|
|
108
|
+
if (!locale && config.localeDetection && requestCookies) {
|
|
109
|
+
const cookieLocale = getLocaleFromCookie(requestCookies, config.locales);
|
|
110
|
+
if (cookieLocale) {
|
|
111
|
+
if (utils.isLocaleSupportedOnDomain(cookieLocale, domain)) {
|
|
112
|
+
locale = cookieLocale;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Prio 3: Use the `accept-language` header
|
|
118
|
+
if (!locale && config.localeDetection && requestHeaders) {
|
|
119
|
+
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales || config.locales, domain.defaultLocale);
|
|
120
|
+
if (headerLocale) {
|
|
121
|
+
locale = headerLocale;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Prio 4: Use default locale
|
|
126
|
+
if (!locale) {
|
|
127
|
+
locale = domain.defaultLocale;
|
|
128
|
+
}
|
|
97
129
|
return {
|
|
98
|
-
locale
|
|
130
|
+
locale,
|
|
131
|
+
domain
|
|
99
132
|
};
|
|
100
133
|
}
|
|
101
134
|
function resolveLocale(config, requestHeaders, requestCookies, pathname) {
|
|
@@ -4,7 +4,6 @@ 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');
|
|
8
7
|
|
|
9
8
|
function useHook(hookName, promise) {
|
|
10
9
|
try {
|
|
@@ -20,8 +19,7 @@ function useHook(hookName, promise) {
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
function useConfig(hookName) {
|
|
23
|
-
|
|
24
|
-
return useHook(hookName, getConfig.default(locale));
|
|
22
|
+
return useHook(hookName, getConfig.default());
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
exports.default = useConfig;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var useConfig = require('./useConfig.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
|
-
|
|
11
|
+
const config = useConfig.default('useLocale');
|
|
12
|
+
return config.locale;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
exports.default = useLocale;
|
|
@@ -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 RequestLocale = require('./RequestLocale.js');
|
|
7
8
|
var getRuntimeConfig = require('next-intl/config');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -22,28 +23,31 @@ function getDefaultTimeZoneImpl() {
|
|
|
22
23
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
23
24
|
}
|
|
24
25
|
const getDefaultTimeZone = React.cache(getDefaultTimeZoneImpl);
|
|
25
|
-
async function receiveRuntimeConfigImpl(
|
|
26
|
-
var _result, _result2;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
async function receiveRuntimeConfigImpl(localeOverride, getConfig) {
|
|
27
|
+
var _result, _result2, _result3;
|
|
28
|
+
// In case the consumer doesn't read `params.locale` and instead provides the
|
|
29
|
+
// `locale` (either in a single-language workflow or because the locale is
|
|
30
|
+
// read from the user settings), don't attempt to read the request locale.
|
|
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);
|
|
30
37
|
if (result instanceof Promise) {
|
|
31
38
|
result = await result;
|
|
32
39
|
}
|
|
33
40
|
return {
|
|
34
41
|
...result,
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
locale: ((_result = result) === null || _result === void 0 ? void 0 : _result.locale) || params.locale,
|
|
43
|
+
now: ((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.now) || getDefaultNow(),
|
|
44
|
+
timeZone: ((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.timeZone) || getDefaultTimeZone()
|
|
37
45
|
};
|
|
38
46
|
}
|
|
39
47
|
const receiveRuntimeConfig = React.cache(receiveRuntimeConfigImpl);
|
|
40
|
-
async function getConfigImpl(
|
|
41
|
-
const runtimeConfig = await receiveRuntimeConfig(
|
|
42
|
-
|
|
43
|
-
...runtimeConfig,
|
|
44
|
-
locale
|
|
45
|
-
};
|
|
46
|
-
return core.initializeConfig(opts);
|
|
48
|
+
async function getConfigImpl(localeOverride) {
|
|
49
|
+
const runtimeConfig = await receiveRuntimeConfig(localeOverride, getRuntimeConfig__default.default);
|
|
50
|
+
return core.initializeConfig(runtimeConfig);
|
|
47
51
|
}
|
|
48
52
|
const getConfig = React.cache(getConfigImpl);
|
|
49
53
|
var getConfig$1 = getConfig;
|
|
@@ -5,7 +5,6 @@ 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');
|
|
9
8
|
|
|
10
9
|
async function getFormatterCachedImpl(locale) {
|
|
11
10
|
const config = await getConfig.default(locale);
|
|
@@ -20,8 +19,7 @@ const getFormatterCached = React.cache(getFormatterCachedImpl);
|
|
|
20
19
|
* you can override it by passing in additional options.
|
|
21
20
|
*/
|
|
22
21
|
async function getFormatter(opts) {
|
|
23
|
-
|
|
24
|
-
return getFormatterCached(locale);
|
|
22
|
+
return getFormatterCached(opts === null || opts === void 0 ? void 0 : opts.locale);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
exports.default = getFormatter;
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var getConfig = require('./getConfig.js');
|
|
6
7
|
|
|
7
|
-
function
|
|
8
|
-
|
|
8
|
+
async function getLocaleCachedImpl() {
|
|
9
|
+
const config = await getConfig.default();
|
|
10
|
+
return Promise.resolve(config.locale);
|
|
9
11
|
}
|
|
12
|
+
const getLocaleCached = React.cache(getLocaleCachedImpl);
|
|
13
|
+
var getLocale = getLocaleCached;
|
|
10
14
|
|
|
11
15
|
exports.default = getLocale;
|
|
@@ -4,7 +4,6 @@ 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');
|
|
8
7
|
|
|
9
8
|
function getMessagesFromConfig(config) {
|
|
10
9
|
if (!config.messages) {
|
|
@@ -18,8 +17,7 @@ async function getMessagesCachedImpl(locale) {
|
|
|
18
17
|
}
|
|
19
18
|
const getMessagesCached = React.cache(getMessagesCachedImpl);
|
|
20
19
|
async function getMessages(opts) {
|
|
21
|
-
|
|
22
|
-
return getMessagesCached(locale);
|
|
20
|
+
return getMessagesCached(opts === null || opts === void 0 ? void 0 : opts.locale);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
exports.default = getMessages;
|
|
@@ -4,7 +4,6 @@ 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');
|
|
8
7
|
|
|
9
8
|
async function getNowCachedImpl(locale) {
|
|
10
9
|
const config = await getConfig.default(locale);
|
|
@@ -12,8 +11,7 @@ async function getNowCachedImpl(locale) {
|
|
|
12
11
|
}
|
|
13
12
|
const getNowCached = React.cache(getNowCachedImpl);
|
|
14
13
|
async function getNow(opts) {
|
|
15
|
-
|
|
16
|
-
return getNowCached(locale);
|
|
14
|
+
return getNowCached(opts === null || opts === void 0 ? void 0 : opts.locale);
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
exports.default = getNow;
|
|
@@ -4,7 +4,6 @@ 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');
|
|
8
7
|
|
|
9
8
|
async function getTimeZoneCachedImpl(locale) {
|
|
10
9
|
const config = await getConfig.default(locale);
|
|
@@ -12,8 +11,7 @@ async function getTimeZoneCachedImpl(locale) {
|
|
|
12
11
|
}
|
|
13
12
|
const getTimeZoneCached = React.cache(getTimeZoneCachedImpl);
|
|
14
13
|
async function getTimeZone(opts) {
|
|
15
|
-
|
|
16
|
-
return getTimeZoneCached(locale);
|
|
14
|
+
return getTimeZoneCached(opts === null || opts === void 0 ? void 0 : opts.locale);
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
exports.default = getTimeZone;
|
|
@@ -6,7 +6,6 @@ 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');
|
|
10
9
|
|
|
11
10
|
// Maintainer note: `getTranslations` has two different call signatures.
|
|
12
11
|
// We need to define these with function overloads, otherwise TypeScript
|
|
@@ -24,7 +23,7 @@ async function getTranslations(namespaceOrOpts) {
|
|
|
24
23
|
locale = namespaceOrOpts.locale;
|
|
25
24
|
namespace = namespaceOrOpts.namespace;
|
|
26
25
|
}
|
|
27
|
-
const config = await getConfig.default(locale
|
|
26
|
+
const config = await getConfig.default(locale);
|
|
28
27
|
return core.createTranslator({
|
|
29
28
|
...config,
|
|
30
29
|
messageFormatCache: messageFormatCache.getMessageFormatCache(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as
|
|
1
|
+
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as t}from"../shared/constants.js";import{isLocaleSupportedOnDomain as n,getHost as l,getFirstPathnameSegment as a,findCaseInsensitiveLocale as c}from"./utils.js";function i(t,n,l){let a;const c=new o({headers:{"accept-language":t.get("accept-language")||void 0}}).languages();try{a=e(c,n,l)}catch(e){}return a}function r(e,o){const t=a(e);return c(t,o)}function u(e,o){if(e.has(t)){var n;const l=null===(n=e.get(t))||void 0===n?void 0:n.value;if(l&&o.includes(l))return l}}function f(e,o,t,n){let l,{defaultLocale:a,localeDetection:c,locales:f}=e;return n&&(l=r(n,f)),!l&&c&&t&&(l=u(t,f)),!l&&c&&o&&(l=i(o,f,a)),l||(l=a),l}function s(e,o,t,a){const c=function(e,o){var t;let n=l(e);if(n=null===(t=n)||void 0===t?void 0:t.replace(/:\d+$/,""),n&&o)return o.find((e=>e.domain===n))}(o,e.domains);if(!c)return{locale:f(e,o,t,a)};let s;if(a){const o=r(a,e.locales);if(o){if(!n(o,c))return{locale:o,domain:c};s=o}}if(!s&&e.localeDetection&&t){const o=u(t,e.locales);o&&n(o,c)&&(s=o)}if(!s&&e.localeDetection&&o){const t=i(o,c.locales||e.locales,c.defaultLocale);t&&(s=t)}return s||(s=c.defaultLocale),{locale:s,domain:c}}function d(e,o,t,n){return e.domains?s(e,o,t,n):{locale:f(e,o,t,n)}}export{d as default,i as getAcceptLanguageLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{use as e}from"react";import
|
|
1
|
+
import{use as e}from"react";import n from"../server/react-server/getConfig.js";function r(r){return function(n,r){try{return e(r)}catch(e){throw e instanceof TypeError&&e.message.includes("Cannot read properties of null (reading 'use')")?new Error("`".concat(n,"` 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}}(r,n())}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"./useConfig.js";function r(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return e("useLocale").locale}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as
|
|
1
|
+
import{cache as o}from"react";import{initializeConfig as n}from"use-intl/core";import{getRequestLocale as t}from"./RequestLocale.js";import e from"next-intl/config";const i=o((function(){return new Date}));const r=o((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const l=o((async function(o,n){var e,l,a;const c={get locale(){return o||t()}};let u=null==n?void 0:n(c);return u instanceof Promise&&(u=await u),{...u,locale:(null===(e=u)||void 0===e?void 0:e.locale)||c.locale,now:(null===(l=u)||void 0===l?void 0:l.now)||i(),timeZone:(null===(a=u)||void 0===a?void 0:a.timeZone)||r()}}));var a=o((async function(o){const t=await l(o,e);return n(t)}));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 n from"./getConfig.js";const r=o((async function(o){const r=await n(o);return t(r)}));async function c(o){return r(null==o?void 0:o.locale)}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cache as o}from"react";import r from"./getConfig.js";var t=o((async function(){const o=await r();return Promise.resolve(o.locale)}));export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as e}from"react";import o from"./getConfig.js";
|
|
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 n=e((async function(e){return t(await o(e))}));async function r(e){return n(null==e?void 0:e.locale)}export{r as default,t as getMessagesFromConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as
|
|
1
|
+
import{cache as n}from"react";import o from"./getConfig.js";const t=n((async function(n){return(await o(n)).now}));async function r(n){return t(null==n?void 0:n.locale)}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cache as t}from"react";import
|
|
1
|
+
import{cache as t}from"react";import n from"./getConfig.js";const o=t((async function(t){return(await n(t)).timeZone}));async function r(t){return o(null==t?void 0:t.locale)}export{r 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 r from"./getConfig.js";var t=e((async function(e){let t,o;"string"==typeof e?t=e:e&&(o=e.locale,t=e.namespace);const m=await r(o);return a({...m,messageFormatCache:s(),namespace:t,messages:m.messages})}));export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),n=require("../shared/constants.js"),o=require("./utils.js");function a(e){return e&&e.__esModule?e:{default:e}}var l=a(t);function c(t,n,o){let a;const c=new l.default({headers:{"accept-language":t.get("accept-language")||void 0}}).languages();try{a=e.match(c,n,o)}catch(e){}return a}function i(e,t){const n=o.getFirstPathnameSegment(e);return o.findCaseInsensitiveLocale(n,t)}function r(e,t){if(e.has(n.COOKIE_LOCALE_NAME)){var o;const a=null===(o=e.get(n.COOKIE_LOCALE_NAME))||void 0===o?void 0:o.value;if(a&&t.includes(a))return a}}function u(e,t,n,o){let a,{defaultLocale:l,localeDetection:u,locales:s}=e;return o&&(a=i(o,s)),!a&&u&&n&&(a=r(n,s)),!a&&u&&t&&(a=c(t,s,l)),a||(a=l),a}function s(e,t,n,a){const l=function(e,t){var n;let a=o.getHost(e);if(a=null===(n=a)||void 0===n?void 0:n.replace(/:\d+$/,""),a&&t)return t.find((e=>e.domain===a))}(t,e.domains);if(!l)return{locale:u(e,t,n,a)};let s;if(a){const t=i(a,e.locales);if(t){if(!o.isLocaleSupportedOnDomain(t,l))return{locale:t,domain:l};s=t}}if(!s&&e.localeDetection&&n){const t=r(n,e.locales);t&&o.isLocaleSupportedOnDomain(t,l)&&(s=t)}if(!s&&e.localeDetection&&t){const n=c(t,l.locales||e.locales,l.defaultLocale);n&&(s=n)}return s||(s=l.defaultLocale),{locale:s,domain:l}}exports.default=function(e,t,n,o){return e.domains?s(e,t,n,o):{locale:u(e,t,n,o)}},exports.getAcceptLanguageLocale=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../server/react-server/getConfig.js")
|
|
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,n){try{return e.use(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}}(n,r.default())};
|
|
@@ -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("./useConfig.js");exports.default=function(){for(var r=arguments.length,t=new Array(r),u=0;u<r;u++)t[u]=arguments[u];return e.default("useLocale").locale};
|
|
@@ -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"),t=require("use-intl/core"),n=require("./RequestLocale.js");function o(e){return e&&e.__esModule?e:{default:e}}var i=o(require("next-intl/config"));const r=e.cache((function(){return new Date}));const c=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const a=e.cache((async function(e,t){var o,i,a;const l={get locale(){return e||n.getRequestLocale()}};let u=null==t?void 0:t(l);return u instanceof Promise&&(u=await u),{...u,locale:(null===(o=u)||void 0===o?void 0:o.locale)||l.locale,now:(null===(i=u)||void 0===i?void 0:i.now)||r(),timeZone:(null===(a=u)||void 0===a?void 0:a.timeZone)||c()}}));var l=e.cache((async function(e){const n=await a(e,i.default);return t.initializeConfig(n)}));exports.default=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),t=require("./getConfig.js")
|
|
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 c=await t.default(e);return r.createFormatter(c)}));exports.default=async function(e){return c(null==e?void 0:e.locale)};
|
|
@@ -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("react"),r=require("./getConfig.js");var t=e.cache((async function(){const e=await r.default();return Promise.resolve(e.locale)}));exports.default=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./getConfig.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./getConfig.js");function s(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 t=e.cache((async function(e){return s(await r.default(e))}));exports.default=async function(e){return t(null==e?void 0:e.locale)},exports.getMessagesFromConfig=s;
|
|
@@ -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"),t=require("./getConfig.js");const r=e.cache((async function(e){return(await t.default(e)).now}));exports.default=async function(e){return r(null==e?void 0:e.locale)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./getConfig.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./getConfig.js");const r=e.cache((async function(e){return(await t.default(e)).timeZone}));exports.default=async function(e){return r(null==e?void 0:e.locale)};
|
|
@@ -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")
|
|
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 t=e.cache((async function(e){let t,c;"string"==typeof e?t=e:e&&(c=e.locale,t=e.namespace);const o=await s.default(c);return a.createTranslator({...o,messageFormatCache:r.getMessageFormatCache(),namespace:t,messages:o.messages})}));exports.default=t;
|
|
@@ -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,
|
|
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';
|
|
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: () => Promise<string>;
|
|
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(localeOverride?: 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.
|
|
3
|
+
"version": "3.12.0-provided-locale.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -16,16 +16,6 @@
|
|
|
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
|
-
},
|
|
29
19
|
"main": "./dist/index.react-client.js",
|
|
30
20
|
"module": "./dist/esm/index.react-client.js",
|
|
31
21
|
"typings": "./dist/types/src/index.react-client.d.ts",
|
|
@@ -82,7 +72,7 @@
|
|
|
82
72
|
"dependencies": {
|
|
83
73
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
84
74
|
"negotiator": "^0.6.3",
|
|
85
|
-
"use-intl": "^3.11.
|
|
75
|
+
"use-intl": "^3.11.3"
|
|
86
76
|
},
|
|
87
77
|
"peerDependencies": {
|
|
88
78
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -100,7 +90,7 @@
|
|
|
100
90
|
"eslint": "^8.54.0",
|
|
101
91
|
"eslint-config-molindo": "^7.0.0",
|
|
102
92
|
"eslint-plugin-deprecation": "^1.4.1",
|
|
103
|
-
"next": "^14.1
|
|
93
|
+
"next": "^14.2.1",
|
|
104
94
|
"path-to-regexp": "^6.2.1",
|
|
105
95
|
"publint": "^0.2.7",
|
|
106
96
|
"react": "^18.2.0",
|
|
@@ -118,7 +108,7 @@
|
|
|
118
108
|
},
|
|
119
109
|
{
|
|
120
110
|
"path": "dist/production/index.react-server.js",
|
|
121
|
-
"limit": "13.
|
|
111
|
+
"limit": "13.8 KB"
|
|
122
112
|
},
|
|
123
113
|
{
|
|
124
114
|
"path": "dist/production/navigation.react-client.js",
|
|
@@ -126,7 +116,7 @@
|
|
|
126
116
|
},
|
|
127
117
|
{
|
|
128
118
|
"path": "dist/production/navigation.react-server.js",
|
|
129
|
-
"limit": "
|
|
119
|
+
"limit": "14.8 KB"
|
|
130
120
|
},
|
|
131
121
|
{
|
|
132
122
|
"path": "dist/production/server.react-client.js",
|
|
@@ -138,8 +128,15 @@
|
|
|
138
128
|
},
|
|
139
129
|
{
|
|
140
130
|
"path": "dist/production/middleware.js",
|
|
141
|
-
"limit": "
|
|
131
|
+
"limit": "6 KB"
|
|
142
132
|
}
|
|
143
133
|
],
|
|
144
|
-
"
|
|
145
|
-
|
|
134
|
+
"scripts": {
|
|
135
|
+
"build": "rm -rf dist && rollup -c",
|
|
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
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
import e from"./getLocale.js";function l(l){return null!=l&&l.locale?Promise.resolve(l.locale):e()}export{l as default};
|
|
@@ -1 +0,0 @@
|
|
|
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()};
|