next-intl 2.4.1 → 2.7.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/README.md +2 -1
- package/dist/next-intl.cjs.development.js +30 -11
- package/dist/next-intl.cjs.development.js.map +1 -1
- package/dist/next-intl.cjs.production.min.js +1 -1
- package/dist/next-intl.cjs.production.min.js.map +1 -1
- package/dist/next-intl.esm.js +21 -2
- package/dist/next-intl.esm.js.map +1 -1
- package/package.json +19 -16
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<br>
|
|
8
8
|
</h1>
|
|
9
9
|
|
|
10
|
-
> A minimal, but complete solution for
|
|
10
|
+
> A minimal, but complete solution for internationalization in Next.js apps.
|
|
11
11
|
|
|
12
12
|
  [<img src="https://img.shields.io/npm/dw/next-intl.svg" />](https://www.npmjs.com/package/next-intl)
|
|
13
13
|
|
|
@@ -18,6 +18,7 @@ This library complements the [internationalized routing](https://nextjs.org/docs
|
|
|
18
18
|
- 🌟 **Proven ICU syntax**: This covers interpolation, plurals, ordinal pluralization, label selection based on enums and rich text. I18n is an essential part of the user experience, therefore this library doesn't compromise on flexibility and never leaves you behind when you need to fine tune a translation.
|
|
19
19
|
- 📅 **Built-in date, time and number formatting**: You can use global formats for a consistent look & feel of your app and integrate them with translations.
|
|
20
20
|
- 💡 **Hooks-only API**: This ensures that you can use the same API for `children` as well as for attributes which expect strings.
|
|
21
|
+
- ✅ **Type-safe**: If you're using TypeScript, you'll benefit from autocompletion for available message keys and compile-time errors for typos.
|
|
21
22
|
- ⚔️ **Battle-tested building blocks**: This library is a minimal wrapper around built-in browser APIs and supplemental lower-level APIs from Format.JS.
|
|
22
23
|
- 🚀 **Fast**: By integrating with both static as well as server side rendering you always get the best possible performance from your app.
|
|
23
24
|
|
|
@@ -2,12 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var router = require('next/router');
|
|
8
|
-
var React =
|
|
6
|
+
var React = require('react');
|
|
9
7
|
var useIntl = require('use-intl');
|
|
10
8
|
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
function _extends() {
|
|
14
|
+
_extends = Object.assign || function (target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = arguments[i];
|
|
17
|
+
|
|
18
|
+
for (var key in source) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
|
+
target[key] = source[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return _extends.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
12
32
|
if (source == null) return {};
|
|
13
33
|
var target = {};
|
|
@@ -23,11 +43,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
23
43
|
return target;
|
|
24
44
|
}
|
|
25
45
|
|
|
46
|
+
var _excluded = ["locale"];
|
|
26
47
|
function NextIntlProvider(_ref) {
|
|
27
48
|
var _useRouter;
|
|
28
49
|
|
|
29
50
|
var locale = _ref.locale,
|
|
30
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
51
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
52
|
|
|
32
53
|
// The router can be undefined if used in a context outside
|
|
33
54
|
// of Next.js (e.g. unit tests, Storybook, ...)
|
|
@@ -38,21 +59,19 @@ function NextIntlProvider(_ref) {
|
|
|
38
59
|
}
|
|
39
60
|
|
|
40
61
|
if (!locale) {
|
|
41
|
-
throw new Error(
|
|
62
|
+
throw new Error("Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`." );
|
|
42
63
|
}
|
|
43
64
|
|
|
44
|
-
return
|
|
65
|
+
return React__default["default"].createElement(useIntl.IntlProvider, _extends({
|
|
45
66
|
locale: locale
|
|
46
67
|
}, rest));
|
|
47
68
|
}
|
|
48
69
|
|
|
70
|
+
exports.NextIntlProvider = NextIntlProvider;
|
|
49
71
|
Object.keys(useIntl).forEach(function (k) {
|
|
50
|
-
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
72
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
51
73
|
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return useIntl[k];
|
|
54
|
-
}
|
|
74
|
+
get: function () { return useIntl[k]; }
|
|
55
75
|
});
|
|
56
76
|
});
|
|
57
|
-
exports.NextIntlProvider = NextIntlProvider;
|
|
58
77
|
//# sourceMappingURL=next-intl.cjs.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.cjs.development.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["NextIntlProvider","locale","rest","nextLocale","useRouter","Error","React","IntlProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-intl.cjs.development.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["NextIntlProvider","locale","rest","nextLocale","useRouter","Error","React","createElement","IntlProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQc,SAAUA,gBAAV,CAAmD,IAAA,EAAA;AAAA,EAAA,IAAA,UAAA,CAAA;;AAAA,EAAvBC,IAAAA,MAAuB,QAAvBA,MAAuB;AAAA,MAAZC,IAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC/D;AACA;AACA,EAAA,IAAMC,UAAU,GAAGC,CAAAA,UAAAA,GAAAA,gBAAS,EAAZ,KAAA,IAAA,GAAA,KAAA,CAAA,GAAG,WAAaH,MAAhC,CAAA;;AAEA,EAAA,IAAI,CAACA,MAAD,IAAWE,UAAf,EAA2B;AACzBF,IAAAA,MAAM,GAAGE,UAAT,CAAA;AACD,GAAA;;AAED,EAAI,IAAA,CAACF,MAAL,EAAa;AACX,IAAA,MAAM,IAAII,KAAJ,CAEA,+IADJ,CADI,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OAAOC,yBAAA,CAAAC,aAAA,CAACC,oBAAD,EAAA,QAAA,CAAA;AAAcP,IAAAA,MAAM,EAAEA,MAAAA;AAAtB,GAAA,EAAkCC,IAAlC,CAAP,CAAA,CAAA;AACD;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/router"),r=require("react"),t=require("use-intl");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(r);function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},u.apply(this,arguments)}var l=["locale"];exports.NextIntlProvider=function(r){var n,a=r.locale,i=function(e,r){if(null==e)return{};var t,n,o={},u=Object.keys(e);for(n=0;n<u.length;n++)r.indexOf(t=u[n])>=0||(o[t]=e[t]);return o}(r,l),c=null==(n=e.useRouter())?void 0:n.locale;if(!a&&c&&(a=c),!a)throw new Error(void 0);return o.default.createElement(t.IntlProvider,u({locale:a},i))},Object.keys(t).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
|
2
2
|
//# sourceMappingURL=next-intl.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.cjs.production.min.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["locale","rest","
|
|
1
|
+
{"version":3,"file":"next-intl.cjs.production.min.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["_ref","_useRouter","locale","rest","_objectWithoutPropertiesLoose","_excluded","nextLocale","useRouter","Error","undefined","React","createElement","IntlProvider","_extends"],"mappings":"udAQc,SAAmDA,GAAA,IAAAC,EAAvBC,IAAAA,OAAWC,oIAAYC,CAAAJ,EAAAK,GAGzDC,EAAU,OAAGC,EAAAA,EAASA,kBAAZ,EAAGN,EAAaC,OAM5B,IAJCA,GAAUI,IACbJ,EAASI,IAGNJ,EACH,MAAM,IAAIM,WAGJC,GAIR,OAAOC,UAAAC,cAACC,EAADA,aAAAC,EAAA,CAAcX,OAAQA,GAAYC"}
|
package/dist/next-intl.esm.js
CHANGED
|
@@ -3,6 +3,24 @@ import React from 'react';
|
|
|
3
3
|
import { IntlProvider } from 'use-intl';
|
|
4
4
|
export * from 'use-intl';
|
|
5
5
|
|
|
6
|
+
function _extends() {
|
|
7
|
+
_extends = Object.assign || function (target) {
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
var source = arguments[i];
|
|
10
|
+
|
|
11
|
+
for (var key in source) {
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
|
+
target[key] = source[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return _extends.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
|
|
6
24
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
7
25
|
if (source == null) return {};
|
|
8
26
|
var target = {};
|
|
@@ -18,11 +36,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
18
36
|
return target;
|
|
19
37
|
}
|
|
20
38
|
|
|
39
|
+
var _excluded = ["locale"];
|
|
21
40
|
function NextIntlProvider(_ref) {
|
|
22
41
|
var _useRouter;
|
|
23
42
|
|
|
24
43
|
var locale = _ref.locale,
|
|
25
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
44
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
26
45
|
|
|
27
46
|
// The router can be undefined if used in a context outside
|
|
28
47
|
// of Next.js (e.g. unit tests, Storybook, ...)
|
|
@@ -36,7 +55,7 @@ function NextIntlProvider(_ref) {
|
|
|
36
55
|
throw new Error(process.env.NODE_ENV !== "production" ? "Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`." : undefined);
|
|
37
56
|
}
|
|
38
57
|
|
|
39
|
-
return React.createElement(IntlProvider,
|
|
58
|
+
return React.createElement(IntlProvider, _extends({
|
|
40
59
|
locale: locale
|
|
41
60
|
}, rest));
|
|
42
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.esm.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["NextIntlProvider","locale","rest","nextLocale","useRouter","Error","undefined","React","IntlProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-intl.esm.js","sources":["../src/NextIntlProvider.tsx"],"sourcesContent":["import {useRouter} from 'next/router';\nimport React, {ComponentProps} from 'react';\nimport {IntlProvider} from 'use-intl';\n\ntype Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {\n locale?: string;\n};\n\nexport default function NextIntlProvider({locale, ...rest}: Props) {\n // The router can be undefined if used in a context outside\n // of Next.js (e.g. unit tests, Storybook, ...)\n const nextLocale = useRouter()?.locale;\n\n if (!locale && nextLocale) {\n locale = nextLocale;\n }\n\n if (!locale) {\n throw new Error(\n __DEV__\n ? \"Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`.\"\n : undefined\n );\n }\n\n return <IntlProvider locale={locale} {...rest} />;\n}\n"],"names":["NextIntlProvider","locale","rest","nextLocale","useRouter","Error","undefined","React","createElement","IntlProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQc,SAAUA,gBAAV,CAAmD,IAAA,EAAA;AAAA,EAAA,IAAA,UAAA,CAAA;;AAAA,EAAvBC,IAAAA,MAAuB,QAAvBA,MAAuB;AAAA,MAAZC,IAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAC/D;AACA;AACA,EAAA,IAAMC,UAAU,GAAGC,CAAAA,UAAAA,GAAAA,SAAS,EAAZ,KAAA,IAAA,GAAA,KAAA,CAAA,GAAG,WAAaH,MAAhC,CAAA;;AAEA,EAAA,IAAI,CAACA,MAAD,IAAWE,UAAf,EAA2B;AACzBF,IAAAA,MAAM,GAAGE,UAAT,CAAA;AACD,GAAA;;AAED,EAAI,IAAA,CAACF,MAAL,EAAa;AACX,IAAA,MAAM,IAAII,KAAJ,CACJ,wCACI,+IADJ,GAEIC,SAHA,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OAAOC,KAAA,CAAAC,aAAA,CAACC,YAAD,EAAA,QAAA,CAAA;AAAcR,IAAAA,MAAM,EAAEA,MAAAA;AAAtB,GAAA,EAAkCC,IAAlC,CAAP,CAAA,CAAA;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.me>",
|
|
6
|
-
"description": "A minimal, but complete solution for
|
|
6
|
+
"description": "A minimal, but complete solution for internationalization in Next.js apps.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/amannn/next-intl"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"start": "
|
|
14
|
-
"build": "
|
|
15
|
-
"test": "TZ=Europe/Berlin
|
|
13
|
+
"start": "dts watch",
|
|
14
|
+
"build": "dts build",
|
|
15
|
+
"test": "TZ=Europe/Berlin dts test",
|
|
16
16
|
"lint": "eslint src test && tsc",
|
|
17
17
|
"prepublishOnly": "yarn test && yarn lint && yarn build && cp ../../README.md ."
|
|
18
18
|
},
|
|
@@ -36,27 +36,30 @@
|
|
|
36
36
|
"next",
|
|
37
37
|
"next.js"
|
|
38
38
|
],
|
|
39
|
+
"jest": {
|
|
40
|
+
"testEnvironment": "jsdom"
|
|
41
|
+
},
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"use-intl": "^2.
|
|
43
|
+
"use-intl": "^2.7.0"
|
|
41
44
|
},
|
|
42
45
|
"peerDependencies": {
|
|
43
46
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
44
|
-
"react": "^16.8.0 || ^17.0.0"
|
|
47
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
|
-
"@testing-library/react": "^
|
|
48
|
-
"@types/react": "^
|
|
49
|
-
"
|
|
50
|
-
"eslint
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"react
|
|
54
|
-
"
|
|
50
|
+
"@testing-library/react": "^13.0.0",
|
|
51
|
+
"@types/react": "^18.0.0",
|
|
52
|
+
"dts-cli": "1.4.0",
|
|
53
|
+
"eslint": "8.12.0",
|
|
54
|
+
"eslint-config-molindo": "6.0.0",
|
|
55
|
+
"next": "^12.1.4",
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"react-dom": "^18.0.0",
|
|
55
58
|
"tslib": "^2.3.1",
|
|
56
59
|
"typescript": "^4.4.4"
|
|
57
60
|
},
|
|
58
61
|
"engines": {
|
|
59
62
|
"node": ">=10"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "36b019fbc9c58d69a9aa7b14076b0aad0e4d9c16"
|
|
62
65
|
}
|