next-intlayer 6.1.5 → 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.
- package/dist/cjs/server/getLocale.cjs +56 -0
- package/dist/cjs/server/getLocale.cjs.map +1 -0
- package/dist/cjs/server/index.cjs +3 -0
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/esm/server/getLocale.mjs +22 -0
- package/dist/esm/server/getLocale.mjs.map +1 -0
- package/dist/esm/server/index.mjs +2 -0
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/types/server/getLocale.d.ts +3 -0
- package/dist/types/server/getLocale.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +1 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var getLocale_exports = {};
|
|
30
|
+
__export(getLocale_exports, {
|
|
31
|
+
getLocale: () => getLocale
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(getLocale_exports);
|
|
34
|
+
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
+
var import_core = require("@intlayer/core");
|
|
36
|
+
var import_headers = require("next/headers.js");
|
|
37
|
+
const getLocale = async () => {
|
|
38
|
+
const { defaultLocale } = import_built.default.internationalization;
|
|
39
|
+
const { headerName, cookieName } = import_built.default.middleware;
|
|
40
|
+
const headersList = await (0, import_headers.headers)();
|
|
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;
|
|
46
|
+
const negotiatorHeaders = {};
|
|
47
|
+
headersList.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
48
|
+
const userFallbackLocale = (0, import_core.localeDetector)(negotiatorHeaders);
|
|
49
|
+
if (userFallbackLocale) return userFallbackLocale;
|
|
50
|
+
return defaultLocale;
|
|
51
|
+
};
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
getLocale
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=getLocale.cjs.map
|
|
@@ -0,0 +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 { 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"]}
|
|
@@ -20,6 +20,7 @@ var server_exports = {};
|
|
|
20
20
|
__export(server_exports, {
|
|
21
21
|
IntlayerServer: () => import_server.IntlayerServer,
|
|
22
22
|
IntlayerServerProvider: () => import_server.IntlayerServerProvider,
|
|
23
|
+
getLocale: () => import_getLocale.getLocale,
|
|
23
24
|
locale: () => import_server.locale,
|
|
24
25
|
t: () => import_server.t,
|
|
25
26
|
useDictionary: () => import_server.useDictionary,
|
|
@@ -32,11 +33,13 @@ __export(server_exports, {
|
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(server_exports);
|
|
34
35
|
var import_server = require("react-intlayer/server");
|
|
36
|
+
var import_getLocale = require('./getLocale.cjs');
|
|
35
37
|
var import_withIntlayer = require('./withIntlayer.cjs');
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
39
|
0 && (module.exports = {
|
|
38
40
|
IntlayerServer,
|
|
39
41
|
IntlayerServerProvider,
|
|
42
|
+
getLocale,
|
|
40
43
|
locale,
|
|
41
44
|
t,
|
|
42
45
|
useDictionary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAWO;AACP,0BAA6B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { getLocale } from './getLocale';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAWO;AACP,uBAA0B;AAC1B,0BAA6B;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import configuration from "@intlayer/config/built";
|
|
2
|
+
import { localeDetector } from "@intlayer/core";
|
|
3
|
+
import { cookies, headers } from "next/headers.js";
|
|
4
|
+
const getLocale = async () => {
|
|
5
|
+
const { defaultLocale } = configuration.internationalization;
|
|
6
|
+
const { headerName, cookieName } = configuration.middleware;
|
|
7
|
+
const headersList = await headers();
|
|
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;
|
|
13
|
+
const negotiatorHeaders = {};
|
|
14
|
+
headersList.forEach((value, key) => negotiatorHeaders[key] = value);
|
|
15
|
+
const userFallbackLocale = localeDetector(negotiatorHeaders);
|
|
16
|
+
if (userFallbackLocale) return userFallbackLocale;
|
|
17
|
+
return defaultLocale;
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
getLocale
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=getLocale.mjs.map
|
|
@@ -0,0 +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 { 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":[]}
|
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
useLoadDynamic,
|
|
11
11
|
useLocale
|
|
12
12
|
} from "react-intlayer/server";
|
|
13
|
+
import { getLocale } from "./getLocale.mjs";
|
|
13
14
|
import { withIntlayer } from "./withIntlayer.mjs";
|
|
14
15
|
export {
|
|
15
16
|
IntlayerServer,
|
|
16
17
|
IntlayerServerProvider,
|
|
18
|
+
getLocale,
|
|
17
19
|
locale,
|
|
18
20
|
t,
|
|
19
21
|
useDictionary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { getLocale } from './getLocale';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;","names":[]}
|
|
@@ -0,0 +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,CA6BjD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { IntlayerServer, IntlayerServerProvider, locale, t, useDictionary, useDictionaryDynamic, useI18n, useIntlayer, useLoadDynamic, useLocale, } from 'react-intlayer/server';
|
|
2
|
+
export { getLocale } from './getLocale';
|
|
2
3
|
export { withIntlayer } from './withIntlayer';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,CAAC,EACD,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,CAAC,EACD,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "6.1.
|
|
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/config": "6.1.
|
|
99
|
-
"@intlayer/
|
|
100
|
-
"
|
|
101
|
-
"@intlayer/webpack": "6.1.
|
|
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.
|
|
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.
|
|
128
|
-
"@intlayer/core": "6.1.
|
|
129
|
-
"@intlayer/webpack": "6.1.
|
|
130
|
-
"
|
|
131
|
-
"intlayer": "6.1.
|
|
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"
|