next-intl 3.2.2 → 3.2.3
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.
|
@@ -7,16 +7,19 @@ var _useLocale = require('use-intl/_useLocale');
|
|
|
7
7
|
var constants = require('../shared/constants.js');
|
|
8
8
|
|
|
9
9
|
function useLocale() {
|
|
10
|
-
let locale;
|
|
11
|
-
|
|
12
10
|
// The types aren't entirely correct here. Outside of Next.js
|
|
13
11
|
// `useParams` can be called, but the return type is `null`.
|
|
14
12
|
const params = navigation.useParams();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine as long as we're in the render phase
|
|
13
|
+
let locale;
|
|
14
|
+
try {
|
|
15
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- False positive
|
|
19
16
|
locale = _useLocale.useLocale();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (typeof (params === null || params === void 0 ? void 0 : params[constants.LOCALE_SEGMENT_NAME]) === 'string') {
|
|
19
|
+
locale = params[constants.LOCALE_SEGMENT_NAME];
|
|
20
|
+
} else {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
return locale;
|
|
22
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useParams as t}from"next/navigation";import{useLocale as o}from"use-intl/_useLocale";import{LOCALE_SEGMENT_NAME as
|
|
1
|
+
import{useParams as t}from"next/navigation";import{useLocale as o}from"use-intl/_useLocale";import{LOCALE_SEGMENT_NAME as r}from"../shared/constants.js";function e(){const e=t();let n;try{n=o()}catch(t){if("string"!=typeof(null==e?void 0:e[r]))throw t;n=e[r]}return n}export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("use-intl/_useLocale"),r=require("../shared/constants.js");exports.default=function(){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("use-intl/_useLocale"),r=require("../shared/constants.js");exports.default=function(){const s=e.useParams();let u;try{u=t.useLocale()}catch(e){if("string"!=typeof(null==s?void 0:s[r.LOCALE_SEGMENT_NAME]))throw e;u=s[r.LOCALE_SEGMENT_NAME]}return u};
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
|
+
"funding": [
|
|
7
|
+
{
|
|
8
|
+
"type": "individual",
|
|
9
|
+
"url": "https://github.com/sponsors/amannn"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
6
12
|
"description": "A minimal, but complete solution for internationalization in Next.js apps.",
|
|
7
13
|
"license": "MIT",
|
|
8
14
|
"homepage": "https://next-intl-docs.vercel.app",
|
|
@@ -74,7 +80,7 @@
|
|
|
74
80
|
"dependencies": {
|
|
75
81
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
76
82
|
"negotiator": "^0.6.3",
|
|
77
|
-
"use-intl": "^3.2.
|
|
83
|
+
"use-intl": "^3.2.3"
|
|
78
84
|
},
|
|
79
85
|
"peerDependencies": {
|
|
80
86
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -85,7 +91,7 @@
|
|
|
85
91
|
"@size-limit/preset-big-lib": "^8.2.6",
|
|
86
92
|
"@testing-library/react": "^13.0.0",
|
|
87
93
|
"@types/negotiator": "^0.6.1",
|
|
88
|
-
"@types/node": "^
|
|
94
|
+
"@types/node": "^20.1.2",
|
|
89
95
|
"@types/react": "18.2.34",
|
|
90
96
|
"@types/react-dom": "^18.2.17",
|
|
91
97
|
"eslint": "^8.54.0",
|
|
@@ -99,12 +105,12 @@
|
|
|
99
105
|
"rollup-plugin-preserve-directives": "0.2.0",
|
|
100
106
|
"size-limit": "^8.2.6",
|
|
101
107
|
"typescript": "^5.2.2",
|
|
102
|
-
"vitest": "^0.
|
|
108
|
+
"vitest": "^1.0.1"
|
|
103
109
|
},
|
|
104
110
|
"size-limit": [
|
|
105
111
|
{
|
|
106
112
|
"path": "dist/production/index.react-client.js",
|
|
107
|
-
"limit": "12.
|
|
113
|
+
"limit": "12.82 KB"
|
|
108
114
|
},
|
|
109
115
|
{
|
|
110
116
|
"path": "dist/production/index.react-server.js",
|
|
@@ -112,11 +118,11 @@
|
|
|
112
118
|
},
|
|
113
119
|
{
|
|
114
120
|
"path": "dist/production/navigation.react-client.js",
|
|
115
|
-
"limit": "2.
|
|
121
|
+
"limit": "2.63 KB"
|
|
116
122
|
},
|
|
117
123
|
{
|
|
118
124
|
"path": "dist/production/navigation.react-server.js",
|
|
119
|
-
"limit": "2.
|
|
125
|
+
"limit": "2.82 KB"
|
|
120
126
|
},
|
|
121
127
|
{
|
|
122
128
|
"path": "dist/production/server.react-client.js",
|
|
@@ -131,5 +137,5 @@
|
|
|
131
137
|
"limit": "5.72 KB"
|
|
132
138
|
}
|
|
133
139
|
],
|
|
134
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "1782e9a56db0a7ee6e67dd4ea12a5f527439fa5e"
|
|
135
141
|
}
|