next-intl 3.0.2 → 3.1.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/navigation/react-server/BaseLink.js +3 -4
- package/dist/development/plugin.js +55 -21
- package/dist/development/react-server/NextIntlClientProvider.js +11 -11
- package/dist/esm/navigation/react-server/BaseLink.js +1 -1
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/react-server/NextIntlClientProvider.js +1 -1
- package/dist/production/navigation/react-server/BaseLink.js +1 -1
- package/dist/production/plugin.js +1 -1
- package/dist/production/react-server/NextIntlClientProvider.js +1 -1
- package/dist/types/src/navigation/react-server/BaseLink.d.ts +1 -1
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +1 -1
- package/dist/types/src/react-server/NextIntlClientProvider.d.ts +1 -1
- package/dist/types/test/react-server/NextIntlClientProvider.test.d.ts +1 -0
- package/package.json +4 -4
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var useLocale = require('../../react-server/useLocale.js');
|
|
8
7
|
var BaseLinkWithLocale = require('../../shared/BaseLinkWithLocale.js');
|
|
8
|
+
var getLocale = require('../../server/getLocale.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
13
|
|
|
14
|
-
function BaseLink(_ref) {
|
|
14
|
+
async function BaseLink(_ref) {
|
|
15
15
|
let {
|
|
16
16
|
locale,
|
|
17
17
|
...rest
|
|
18
18
|
} = _ref;
|
|
19
|
-
const defaultLocale = useLocale.default();
|
|
20
19
|
return /*#__PURE__*/React__default.default.createElement(BaseLinkWithLocale.default, _rollupPluginBabelHelpers.extends({
|
|
21
|
-
locale: locale ||
|
|
20
|
+
locale: locale || (await getLocale.default())
|
|
22
21
|
}, rest));
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -10,38 +10,72 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
10
10
|
|
|
11
11
|
/* eslint-env node */
|
|
12
12
|
|
|
13
|
-
function resolveI18nPath(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
function resolveI18nPath(providedPath, cwd) {
|
|
14
|
+
function resolvePath(pathname) {
|
|
15
|
+
const parts = [];
|
|
16
|
+
if (cwd) parts.push(cwd);
|
|
17
|
+
parts.push(pathname);
|
|
18
|
+
return path__default.default.resolve(...parts);
|
|
19
|
+
}
|
|
20
|
+
function pathExists(pathname) {
|
|
21
|
+
return fs__default.default.existsSync(resolvePath(pathname));
|
|
22
|
+
}
|
|
23
|
+
if (providedPath) {
|
|
24
|
+
if (!pathExists(providedPath)) {
|
|
25
|
+
throw new Error("Could not find i18n config at ".concat(providedPath, ", please provide a valid path."));
|
|
19
26
|
}
|
|
27
|
+
return providedPath;
|
|
20
28
|
} else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
for (const candidate of ['./i18n.tsx', './i18n.ts', './i18n.js', './i18n.jsx', './src/i18n.tsx', './src/i18n.ts', './src/i18n.js', './src/i18n.jsx']) {
|
|
30
|
+
if (pathExists(candidate)) {
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
24
33
|
}
|
|
34
|
+
throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n");
|
|
25
35
|
}
|
|
26
|
-
return i18nPath;
|
|
27
36
|
}
|
|
28
37
|
function initPlugin(i18nPath, nextConfig) {
|
|
29
38
|
if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
|
|
30
39
|
console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n");
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const useTurbo = process.env.TURBOPACK != null;
|
|
42
|
+
let nextIntlConfig;
|
|
43
|
+
if (useTurbo) {
|
|
44
|
+
var _nextConfig$experimen, _nextConfig$experimen2;
|
|
45
|
+
if (i18nPath && i18nPath.startsWith('/')) {
|
|
46
|
+
throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + i18nPath + '\n');
|
|
47
|
+
}
|
|
48
|
+
nextIntlConfig = {
|
|
49
|
+
experimental: {
|
|
50
|
+
...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental),
|
|
51
|
+
turbo: {
|
|
52
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen = nextConfig.experimental) === null || _nextConfig$experimen === void 0 ? void 0 : _nextConfig$experimen.turbo),
|
|
53
|
+
resolveAlias: {
|
|
54
|
+
...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen2 = nextConfig.experimental) === null || _nextConfig$experimen2 === void 0 || (_nextConfig$experimen2 = _nextConfig$experimen2.turbo) === null || _nextConfig$experimen2 === void 0 ? void 0 : _nextConfig$experimen2.resolveAlias),
|
|
55
|
+
// Turbo aliases don't work with absolute
|
|
56
|
+
// paths (see error handling above)
|
|
57
|
+
'next-intl/config': resolveI18nPath(i18nPath)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
36
60
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
nextIntlConfig = {
|
|
64
|
+
webpack() {
|
|
65
|
+
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
66
|
+
_ref[_key] = arguments[_key];
|
|
67
|
+
}
|
|
68
|
+
let [config, options] = _ref;
|
|
69
|
+
// Webpack requires absolute paths
|
|
70
|
+
config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
|
|
71
|
+
if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
|
|
72
|
+
return nextConfig.webpack(config, options);
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
41
75
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return Object.assign({}, nextConfig, nextIntlConfig);
|
|
45
79
|
}
|
|
46
80
|
module.exports = function withNextIntl(i18nPath) {
|
|
47
81
|
return nextConfig => initPlugin(i18nPath, nextConfig);
|
|
@@ -5,28 +5,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var NextIntlClientProvider$1 = require('../shared/NextIntlClientProvider.js');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
8
|
+
var getLocale = require('../server/getLocale.js');
|
|
9
|
+
var getNow = require('../server/getNow.js');
|
|
10
|
+
var getTimeZone = require('../server/getTimeZone.js');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
15
15
|
|
|
16
|
-
function NextIntlClientProvider(_ref) {
|
|
16
|
+
async function NextIntlClientProvider(_ref) {
|
|
17
17
|
let {
|
|
18
18
|
locale,
|
|
19
19
|
now,
|
|
20
20
|
timeZone,
|
|
21
21
|
...rest
|
|
22
22
|
} = _ref;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
locale: locale !== null && locale !== void 0 ? locale :
|
|
28
|
-
now: now !== null && now !== void 0 ? now :
|
|
29
|
-
timeZone: timeZone !== null && timeZone !== void 0 ? timeZone :
|
|
23
|
+
return /*#__PURE__*/React__default.default.createElement(NextIntlClientProvider$1.default
|
|
24
|
+
// We need to be careful about potentially reading from headers here.
|
|
25
|
+
// See https://github.com/amannn/next-intl/issues/631
|
|
26
|
+
, _rollupPluginBabelHelpers.extends({
|
|
27
|
+
locale: locale !== null && locale !== void 0 ? locale : await getLocale.default(),
|
|
28
|
+
now: now !== null && now !== void 0 ? now : await getNow.default(),
|
|
29
|
+
timeZone: timeZone !== null && timeZone !== void 0 ? timeZone : await getTimeZone.default()
|
|
30
30
|
}, rest));
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../../
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../../shared/BaseLinkWithLocale.js";import a from"../../server/getLocale.js";async function l(l){let{locale:o,...s}=l;return r.createElement(t,e({locale:o||await a()},s))}export{l as default};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"fs";import e from"path";function t(t,o){
|
|
1
|
+
import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return o=>function(n,o){let r;if(null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n"),null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r={experimental:{...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}}else r={webpack(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,a]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,a):l}};return Object.assign({},o,r)}(n,o)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import
|
|
1
|
+
import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../shared/NextIntlClientProvider.js";import o from"../server/getLocale.js";import l from"../server/getNow.js";import a from"../server/getTimeZone.js";async function i(i){let{locale:n,now:m,timeZone:s,...p}=i;return r.createElement(t,e({locale:null!=n?n:await o(),now:null!=m?m:await l(),timeZone:null!=s?s:await a()},p))}export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../shared/BaseLinkWithLocale.js"),l=require("../../server/getLocale.js");function a(e){return e&&e.__esModule?e:{default:e}}var u=a(r);exports.default=async function(r){let{locale:a,...s}=r;return u.default.createElement(t.default,e.extends({locale:a||await l.default()},s))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var
|
|
1
|
+
"use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var o=t(n),r=t(e);function i(n,e){function t(n){return o.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),r.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return e=>function(n,e){let t;if(null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/packages/example-app-router-migration\n"),null!=process.env.TURBOPACK){var o,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t={experimental:{...null==e?void 0:e.experimental,turbo:{...null==e||null===(o=e.experimental)||void 0===o?void 0:o.turbo,resolveAlias:{...null==e||null===(s=e.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":i(n)}}}}}else t={webpack(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];let[l,u]=o;return l.resolve.alias["next-intl/config"]=r.default.resolve(l.context,i(n,l.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(l,u):l}};return Object.assign({},e,t)}(n,e)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/NextIntlClientProvider.js"),l=require("../server/getLocale.js"),u=require("../server/getNow.js"),a=require("../server/getTimeZone.js");function n(e){return e&&e.__esModule?e:{default:e}}var i=n(r);exports.default=async function(r){let{locale:n,now:o,timeZone:s,...d}=r;return i.default.createElement(t.default,e.extends({locale:null!=n?n:await l.default(),now:null!=o?o:await u.default(),timeZone:null!=s?s:await a.default()},d))};
|
|
@@ -4,5 +4,5 @@ import { AllLocales } from '../../shared/types';
|
|
|
4
4
|
type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWithLocale>, 'locale'> & {
|
|
5
5
|
locale?: Locales[number];
|
|
6
6
|
};
|
|
7
|
-
export default function BaseLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): React.JSX.Element
|
|
7
|
+
export default function BaseLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): Promise<React.JSX.Element>;
|
|
8
8
|
export {};
|
|
@@ -37,7 +37,7 @@ export default function createSharedPathnamesNavigation<Locales extends AllLocal
|
|
|
37
37
|
locale: string;
|
|
38
38
|
}, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
39
39
|
locale?: Locales[number] | undefined;
|
|
40
|
-
}) => import("react").JSX.Element
|
|
40
|
+
}) => Promise<import("react").JSX.Element>;
|
|
41
41
|
redirect: typeof baseRedirect;
|
|
42
42
|
usePathname: () => never;
|
|
43
43
|
useRouter: () => never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
2
|
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider';
|
|
3
3
|
type Props = ComponentProps<typeof BaseNextIntlClientProvider>;
|
|
4
|
-
export default function NextIntlClientProvider({ locale, now, timeZone, ...rest }: Props): React.JSX.Element
|
|
4
|
+
export default function NextIntlClientProvider({ locale, now, timeZone, ...rest }: Props): Promise<React.JSX.Element>;
|
|
5
5
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "A minimal, but complete solution for internationalization in Next.js apps.",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
75
75
|
"negotiator": "^0.6.3",
|
|
76
|
-
"use-intl": "^3.0
|
|
76
|
+
"use-intl": "^3.1.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"eslint": "^8.46.0",
|
|
90
90
|
"eslint-config-molindo": "^7.0.0",
|
|
91
91
|
"eslint-plugin-deprecation": "^1.4.1",
|
|
92
|
-
"next": "14.0.
|
|
92
|
+
"next": "14.0.3",
|
|
93
93
|
"path-to-regexp": "^6.2.1",
|
|
94
94
|
"react": "^18.2.0",
|
|
95
95
|
"react-dom": "^18.2.0",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"limit": "5.7 KB"
|
|
126
126
|
}
|
|
127
127
|
],
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "12d1bb5ea05e2e41b036d0d68c59ff13a946f841"
|
|
129
129
|
}
|