next-intlayer 6.1.6-canary.0 → 6.1.6
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.
|
@@ -33,13 +33,16 @@ __export(getLocale_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(getLocale_exports);
|
|
34
34
|
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
35
|
var import_core = require("@intlayer/core");
|
|
36
|
-
var import_headers = require("next/headers");
|
|
36
|
+
var import_headers = require("next/headers.js");
|
|
37
37
|
const getLocale = async () => {
|
|
38
38
|
const { defaultLocale } = import_built.default.internationalization;
|
|
39
|
-
const { headerName } = import_built.default.middleware;
|
|
39
|
+
const { headerName, cookieName } = import_built.default.middleware;
|
|
40
40
|
const headersList = await (0, import_headers.headers)();
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const headerLocale = headersList.get(headerName);
|
|
42
|
+
if (headerLocale) return headerLocale;
|
|
43
|
+
const cookiesList = await (0, import_headers.cookies)();
|
|
44
|
+
const cookieLocale = cookiesList.get(cookieName)?.value;
|
|
45
|
+
if (cookieLocale) return cookieLocale;
|
|
43
46
|
const negotiatorHeaders = {};
|
|
44
47
|
headersList.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
45
48
|
const userFallbackLocale = (0, import_core.localeDetector)(negotiatorHeaders);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { Locales } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { localeDetector } from '@intlayer/core';\nimport { headers } from 'next/headers';\n\n// Helper function to extract locale from referer URL\nexport const getLocale = async (): Promise<Locales> => {\n const { defaultLocale } = configuration.internationalization;\n const { headerName } = configuration.middleware;\n\n const headersList = await headers();\n\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { Locales } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { localeDetector } from '@intlayer/core';\nimport { cookies, headers } from 'next/headers.js';\n\n// Helper function to extract locale from referer URL\nexport const getLocale = async (): Promise<Locales> => {\n const { defaultLocale } = configuration.internationalization;\n const { headerName, cookieName } = configuration.middleware;\n\n // 1 - Try to pick the locale selected using the headers\n const headersList = await headers();\n\n const headerLocale = headersList.get(headerName) as Locales | undefined;\n\n if (headerLocale) return headerLocale;\n\n // 2 - Try to pick the locale selected using the cookies\n const cookiesList = await cookies();\n const cookieLocale = cookiesList.get(cookieName)?.value as\n | Locales\n | undefined;\n if (cookieLocale) return cookieLocale;\n\n // 3 - Try to pick the locale selected using the browser language preference\n const negotiatorHeaders: Record<string, string> = {};\n\n headersList.forEach((value, key) => (negotiatorHeaders[key] = value));\n\n const userFallbackLocale = localeDetector(negotiatorHeaders);\n\n // 4 - Fallback to default locale\n if (userFallbackLocale) return userFallbackLocale as Locales;\n\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0B;AAC1B,kBAA+B;AAC/B,qBAAiC;AAG1B,MAAM,YAAY,YAA8B;AACrD,QAAM,EAAE,cAAc,IAAI,aAAAA,QAAc;AACxC,QAAM,EAAE,YAAY,WAAW,IAAI,aAAAA,QAAc;AAGjD,QAAM,cAAc,UAAM,wBAAQ;AAElC,QAAM,eAAe,YAAY,IAAI,UAAU;AAE/C,MAAI,aAAc,QAAO;AAGzB,QAAM,cAAc,UAAM,wBAAQ;AAClC,QAAM,eAAe,YAAY,IAAI,UAAU,GAAG;AAGlD,MAAI,aAAc,QAAO;AAGzB,QAAM,oBAA4C,CAAC;AAEnD,cAAY,QAAQ,CAAC,OAAO,QAAS,kBAAkB,GAAG,IAAI,KAAM;AAEpE,QAAM,yBAAqB,4BAAe,iBAAiB;AAG3D,MAAI,mBAAoB,QAAO;AAE/B,SAAO;AACT;","names":["configuration"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import configuration from "@intlayer/config/built";
|
|
2
2
|
import { localeDetector } from "@intlayer/core";
|
|
3
|
-
import { headers } from "next/headers";
|
|
3
|
+
import { cookies, headers } from "next/headers.js";
|
|
4
4
|
const getLocale = async () => {
|
|
5
5
|
const { defaultLocale } = configuration.internationalization;
|
|
6
|
-
const { headerName } = configuration.middleware;
|
|
6
|
+
const { headerName, cookieName } = configuration.middleware;
|
|
7
7
|
const headersList = await headers();
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
8
|
+
const headerLocale = headersList.get(headerName);
|
|
9
|
+
if (headerLocale) return headerLocale;
|
|
10
|
+
const cookiesList = await cookies();
|
|
11
|
+
const cookieLocale = cookiesList.get(cookieName)?.value;
|
|
12
|
+
if (cookieLocale) return cookieLocale;
|
|
10
13
|
const negotiatorHeaders = {};
|
|
11
14
|
headersList.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
12
15
|
const userFallbackLocale = localeDetector(negotiatorHeaders);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { Locales } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { localeDetector } from '@intlayer/core';\nimport { headers } from 'next/headers';\n\n// Helper function to extract locale from referer URL\nexport const getLocale = async (): Promise<Locales> => {\n const { defaultLocale } = configuration.internationalization;\n const { headerName } = configuration.middleware;\n\n const headersList = await headers();\n\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { Locales } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { localeDetector } from '@intlayer/core';\nimport { cookies, headers } from 'next/headers.js';\n\n// Helper function to extract locale from referer URL\nexport const getLocale = async (): Promise<Locales> => {\n const { defaultLocale } = configuration.internationalization;\n const { headerName, cookieName } = configuration.middleware;\n\n // 1 - Try to pick the locale selected using the headers\n const headersList = await headers();\n\n const headerLocale = headersList.get(headerName) as Locales | undefined;\n\n if (headerLocale) return headerLocale;\n\n // 2 - Try to pick the locale selected using the cookies\n const cookiesList = await cookies();\n const cookieLocale = cookiesList.get(cookieName)?.value as\n | Locales\n | undefined;\n if (cookieLocale) return cookieLocale;\n\n // 3 - Try to pick the locale selected using the browser language preference\n const negotiatorHeaders: Record<string, string> = {};\n\n headersList.forEach((value, key) => (negotiatorHeaders[key] = value));\n\n const userFallbackLocale = localeDetector(negotiatorHeaders);\n\n // 4 - Fallback to default locale\n if (userFallbackLocale) return userFallbackLocale as Locales;\n\n return defaultLocale;\n};\n"],"mappings":"AACA,OAAO,mBAAmB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,eAAe;AAG1B,MAAM,YAAY,YAA8B;AACrD,QAAM,EAAE,cAAc,IAAI,cAAc;AACxC,QAAM,EAAE,YAAY,WAAW,IAAI,cAAc;AAGjD,QAAM,cAAc,MAAM,QAAQ;AAElC,QAAM,eAAe,YAAY,IAAI,UAAU;AAE/C,MAAI,aAAc,QAAO;AAGzB,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,eAAe,YAAY,IAAI,UAAU,GAAG;AAGlD,MAAI,aAAc,QAAO;AAGzB,QAAM,oBAA4C,CAAC;AAEnD,cAAY,QAAQ,CAAC,OAAO,QAAS,kBAAkB,GAAG,IAAI,KAAM;AAEpE,QAAM,qBAAqB,eAAe,iBAAiB;AAG3D,MAAI,mBAAoB,QAAO;AAE/B,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../../src/server/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../../src/server/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,OAAO,CA6BjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "6.1.6
|
|
3
|
+
"version": "6.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
|
|
6
6
|
"keywords": [
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"deepmerge": "^4.3.1",
|
|
96
96
|
"node-loader": "^2.1.0",
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"@intlayer/
|
|
99
|
-
"@intlayer/core": "6.1.6
|
|
100
|
-
"
|
|
101
|
-
"@intlayer/
|
|
102
|
-
"
|
|
97
|
+
"@intlayer/chokidar": "6.1.6",
|
|
98
|
+
"@intlayer/config": "6.1.6",
|
|
99
|
+
"@intlayer/core": "6.1.6",
|
|
100
|
+
"react-intlayer": "6.1.6",
|
|
101
|
+
"@intlayer/webpack": "6.1.6",
|
|
102
|
+
"@intlayer/dictionaries-entry": "6.1.6"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@types/node": "^24.5.2",
|
|
@@ -118,18 +118,18 @@
|
|
|
118
118
|
"@utils/ts-config": "1.0.4",
|
|
119
119
|
"@utils/ts-config-types": "1.0.4",
|
|
120
120
|
"@utils/tsup-config": "1.0.4",
|
|
121
|
-
"intlayer": "6.1.6
|
|
121
|
+
"intlayer": "6.1.6"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
124
|
"next": ">=14.0.0",
|
|
125
125
|
"react": ">=16.0.0",
|
|
126
126
|
"react-dom": ">=16.0.0",
|
|
127
|
-
"@intlayer/config": "6.1.6
|
|
128
|
-
"@intlayer/
|
|
129
|
-
"intlayer": "6.1.6
|
|
130
|
-
"
|
|
131
|
-
"@intlayer/
|
|
132
|
-
"
|
|
127
|
+
"@intlayer/config": "6.1.6",
|
|
128
|
+
"@intlayer/core": "6.1.6",
|
|
129
|
+
"@intlayer/webpack": "6.1.6",
|
|
130
|
+
"react-intlayer": "6.1.6",
|
|
131
|
+
"@intlayer/dictionaries-entry": "6.1.6",
|
|
132
|
+
"intlayer": "6.1.6"
|
|
133
133
|
},
|
|
134
134
|
"engines": {
|
|
135
135
|
"node": ">=14.18"
|