next-intl 2.3.3 → 2.3.4
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/next-intl.cjs.development.js +9 -2
- 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 +9 -2
- package/dist/next-intl.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/NextIntlProvider.tsx +7 -2
|
@@ -24,11 +24,18 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function NextIntlProvider(_ref) {
|
|
27
|
+
var _useRouter;
|
|
28
|
+
|
|
27
29
|
var locale = _ref.locale,
|
|
28
30
|
rest = _objectWithoutPropertiesLoose(_ref, ["locale"]);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// The router can be undefined if used in a context outside
|
|
33
|
+
// of Next.js (e.g. unit tests, Storybook, ...)
|
|
34
|
+
var nextLocale = (_useRouter = router.useRouter()) == null ? void 0 : _useRouter.locale;
|
|
35
|
+
|
|
36
|
+
if (!locale && nextLocale) {
|
|
37
|
+
locale = nextLocale;
|
|
38
|
+
}
|
|
32
39
|
|
|
33
40
|
if (!locale) {
|
|
34
41
|
throw new Error( "Couldn't determine locale. Please make sure you use internationalized routing or alternatively pass an explicit locale to `NextIntlProvider`." );
|
|
@@ -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 const nextLocale = useRouter()
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;SAQwBA;;;MAAkBC,cAAAA;MAAWC;;AACnD;AACA;AACA,MAAMC,UAAU,iBAAGC,gBAAS,EAAZ,qBAAG,WAAaH,MAAhC;;AAEA,MAAI,CAACA,MAAD,IAAWE,UAAf,EAA2B;AACzBF,IAAAA,MAAM,GAAGE,UAAT;AACD;;AAED,MAAI,CAACF,MAAL,EAAa;AACX,UAAM,IAAII,KAAJ,EAEA,+IADJ,CADI,CAAN;AAKD;;AAED,SAAOC,mBAAA,CAACC,oBAAD;AAAcN,IAAAA,MAAM,EAAEA;KAAYC,KAAlC,CAAP;AACD;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("next/router"),t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("use-intl");Object.keys(n).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),exports.NextIntlProvider=function(e){var o=e.locale,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("next/router"),t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("use-intl");Object.keys(n).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),exports.NextIntlProvider=function(e){var o,u=e.locale,l=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}(e,["locale"]),i=null==(o=r.useRouter())?void 0:o.locale;if(!u&&i&&(u=i),!u)throw new Error(void 0);return t.createElement(n.IntlProvider,Object.assign({locale:u},l))};
|
|
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 const nextLocale = useRouter()
|
|
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","nextLocale","useRouter","_useRouter","Error","undefined","React","IntlProvider"],"mappings":"6WAQ0CA,IAAAA,OAAWC,mJAG7CC,WAAaC,sBAAAC,EAAaJ,WAE3BA,GAAUE,IACbF,EAASE,IAGNF,QACG,IAAIK,WAGJC,UAIDC,gBAACC,8BAAaR,OAAQA,GAAYC"}
|
package/dist/next-intl.esm.js
CHANGED
|
@@ -19,11 +19,18 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function NextIntlProvider(_ref) {
|
|
22
|
+
var _useRouter;
|
|
23
|
+
|
|
22
24
|
var locale = _ref.locale,
|
|
23
25
|
rest = _objectWithoutPropertiesLoose(_ref, ["locale"]);
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// The router can be undefined if used in a context outside
|
|
28
|
+
// of Next.js (e.g. unit tests, Storybook, ...)
|
|
29
|
+
var nextLocale = (_useRouter = useRouter()) == null ? void 0 : _useRouter.locale;
|
|
30
|
+
|
|
31
|
+
if (!locale && nextLocale) {
|
|
32
|
+
locale = nextLocale;
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
if (!locale) {
|
|
29
36
|
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);
|
|
@@ -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 const nextLocale = useRouter()
|
|
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":";;;;;;;;;;;;;;;;;;;;SAQwBA;;;MAAkBC,cAAAA;MAAWC;;AACnD;AACA;AACA,MAAMC,UAAU,iBAAGC,SAAS,EAAZ,qBAAG,WAAaH,MAAhC;;AAEA,MAAI,CAACA,MAAD,IAAWE,UAAf,EAA2B;AACzBF,IAAAA,MAAM,GAAGE,UAAT;AACD;;AAED,MAAI,CAACF,MAAL,EAAa;AACX,UAAM,IAAII,KAAJ,CACJ,wCACI,+IADJ,GAEIC,SAHA,CAAN;AAKD;;AAED,SAAOC,mBAAA,CAACC,YAAD;AAAcP,IAAAA,MAAM,EAAEA;KAAYC,KAAlC,CAAP;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.me>",
|
|
6
6
|
"description": "A minimal, but complete solution for managing translations, date and number formatting in Next.js apps.",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"next.js"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"use-intl": "^2.3.
|
|
40
|
+
"use-intl": "^2.3.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=10"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "674e4837d625785d1c4242d742f811b7383d8f89"
|
|
62
62
|
}
|
package/src/NextIntlProvider.tsx
CHANGED
|
@@ -7,8 +7,13 @@ type Props = Omit<ComponentProps<typeof IntlProvider>, 'locale'> & {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default function NextIntlProvider({locale, ...rest}: Props) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// The router can be undefined if used in a context outside
|
|
11
|
+
// of Next.js (e.g. unit tests, Storybook, ...)
|
|
12
|
+
const nextLocale = useRouter()?.locale;
|
|
13
|
+
|
|
14
|
+
if (!locale && nextLocale) {
|
|
15
|
+
locale = nextLocale;
|
|
16
|
+
}
|
|
12
17
|
|
|
13
18
|
if (!locale) {
|
|
14
19
|
throw new Error(
|