Initial boiler plate project
This commit is contained in:
2
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.d.ts
generated
vendored
Normal file
2
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { DomainLocale } from '../../../server/config-shared';
|
||||
export declare function detectDomainLocale(domainItems?: DomainLocale[], hostname?: string, detectedLocale?: string): DomainLocale | undefined;
|
||||
26
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
generated
vendored
Normal file
26
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "detectDomainLocale", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return detectDomainLocale;
|
||||
}
|
||||
});
|
||||
function detectDomainLocale(domainItems, hostname, detectedLocale) {
|
||||
if (!domainItems) return;
|
||||
if (detectedLocale) {
|
||||
detectedLocale = detectedLocale.toLowerCase();
|
||||
}
|
||||
for (const item of domainItems){
|
||||
var _item_domain, _item_locales;
|
||||
// remove port if present
|
||||
const domainHostname = (_item_domain = item.domain) == null ? void 0 : _item_domain.split(":", 1)[0].toLowerCase();
|
||||
if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((_item_locales = item.locales) == null ? void 0 : _item_locales.some((locale)=>locale.toLowerCase() === detectedLocale))) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=detect-domain-locale.js.map
|
||||
1
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js.map
generated
vendored
Normal file
1
node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/detect-domain-locale.ts"],"names":["detectDomainLocale","domainItems","hostname","detectedLocale","toLowerCase","item","domainHostname","domain","split","defaultLocale","locales","some","locale"],"mappings":";;;;+BAEgBA;;;eAAAA;;;AAAT,SAASA,mBACdC,WAA4B,EAC5BC,QAAiB,EACjBC,cAAuB;IAEvB,IAAI,CAACF,aAAa;IAElB,IAAIE,gBAAgB;QAClBA,iBAAiBA,eAAeC,WAAW;IAC7C;IAEA,KAAK,MAAMC,QAAQJ,YAAa;YAEPI,cAIrBA;QALF,yBAAyB;QACzB,MAAMC,kBAAiBD,eAAAA,KAAKE,MAAM,qBAAXF,aAAaG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAACJ,WAAW;QAChE,IACEF,aAAaI,kBACbH,mBAAmBE,KAAKI,aAAa,CAACL,WAAW,QACjDC,gBAAAA,KAAKK,OAAO,qBAAZL,cAAcM,IAAI,CAAC,CAACC,SAAWA,OAAOR,WAAW,OAAOD,kBACxD;YACA,OAAOE;QACT;IACF;AACF"}
|
||||
21
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.d.ts
generated
vendored
Normal file
21
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import type { DomainLocale } from '../../../server/config';
|
||||
import type { I18NConfig } from '../../../server/config-shared';
|
||||
interface Options {
|
||||
defaultLocale: string;
|
||||
domainLocale?: DomainLocale;
|
||||
headers?: {
|
||||
[key: string]: string | string[] | undefined;
|
||||
};
|
||||
nextConfig: {
|
||||
basePath?: string;
|
||||
i18n?: I18NConfig | null;
|
||||
trailingSlash?: boolean;
|
||||
};
|
||||
pathLocale?: string;
|
||||
urlParsed: {
|
||||
hostname?: string | null;
|
||||
pathname: string;
|
||||
};
|
||||
}
|
||||
export declare function getLocaleRedirect({ defaultLocale, domainLocale, pathLocale, headers, nextConfig, urlParsed, }: Options): string | undefined;
|
||||
export {};
|
||||
63
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js
generated
vendored
Normal file
63
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getLocaleRedirect", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getLocaleRedirect;
|
||||
}
|
||||
});
|
||||
const _acceptheader = require("../../../server/accept-header");
|
||||
const _denormalizepagepath = require("../page-path/denormalize-page-path");
|
||||
const _detectdomainlocale = require("./detect-domain-locale");
|
||||
const _formaturl = require("../router/utils/format-url");
|
||||
const _getcookieparser = require("../../../server/api-utils/get-cookie-parser");
|
||||
function getLocaleFromCookie(i18n, headers) {
|
||||
if (headers === void 0) headers = {};
|
||||
var _getCookieParser_NEXT_LOCALE, _getCookieParser;
|
||||
const nextLocale = (_getCookieParser = (0, _getcookieparser.getCookieParser)(headers || {})()) == null ? void 0 : (_getCookieParser_NEXT_LOCALE = _getCookieParser.NEXT_LOCALE) == null ? void 0 : _getCookieParser_NEXT_LOCALE.toLowerCase();
|
||||
return nextLocale ? i18n.locales.find((locale)=>nextLocale === locale.toLowerCase()) : undefined;
|
||||
}
|
||||
function detectLocale(param) {
|
||||
let { i18n, headers, domainLocale, preferredLocale, pathLocale } = param;
|
||||
return pathLocale || (domainLocale == null ? void 0 : domainLocale.defaultLocale) || getLocaleFromCookie(i18n, headers) || preferredLocale || i18n.defaultLocale;
|
||||
}
|
||||
function getAcceptPreferredLocale(i18n, headers) {
|
||||
if ((headers == null ? void 0 : headers["accept-language"]) && !Array.isArray(headers["accept-language"])) {
|
||||
try {
|
||||
return (0, _acceptheader.acceptLanguage)(headers["accept-language"], i18n.locales);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
function getLocaleRedirect(param) {
|
||||
let { defaultLocale, domainLocale, pathLocale, headers, nextConfig, urlParsed } = param;
|
||||
if (nextConfig.i18n && nextConfig.i18n.localeDetection !== false && (0, _denormalizepagepath.denormalizePagePath)(urlParsed.pathname) === "/") {
|
||||
const preferredLocale = getAcceptPreferredLocale(nextConfig.i18n, headers);
|
||||
const detectedLocale = detectLocale({
|
||||
i18n: nextConfig.i18n,
|
||||
preferredLocale,
|
||||
headers,
|
||||
pathLocale,
|
||||
domainLocale
|
||||
});
|
||||
const preferredDomain = (0, _detectdomainlocale.detectDomainLocale)(nextConfig.i18n.domains, undefined, preferredLocale);
|
||||
if (domainLocale && preferredDomain) {
|
||||
const isPDomain = preferredDomain.domain === domainLocale.domain;
|
||||
const isPLocale = preferredDomain.defaultLocale === preferredLocale;
|
||||
if (!isPDomain || !isPLocale) {
|
||||
const scheme = "http" + (preferredDomain.http ? "" : "s");
|
||||
const rlocale = isPLocale ? "" : preferredLocale;
|
||||
return scheme + "://" + preferredDomain.domain + "/" + rlocale;
|
||||
}
|
||||
}
|
||||
if (detectedLocale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
||||
return (0, _formaturl.formatUrl)({
|
||||
...urlParsed,
|
||||
pathname: (nextConfig.basePath || "") + "/" + detectedLocale + (nextConfig.trailingSlash ? "/" : "")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-locale-redirect.js.map
|
||||
1
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js.map
generated
vendored
Normal file
1
node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/get-locale-redirect.ts"],"names":["getLocaleRedirect","getLocaleFromCookie","i18n","headers","getCookieParser","nextLocale","NEXT_LOCALE","toLowerCase","locales","find","locale","undefined","detectLocale","domainLocale","preferredLocale","pathLocale","defaultLocale","getAcceptPreferredLocale","Array","isArray","acceptLanguage","err","nextConfig","urlParsed","localeDetection","denormalizePagePath","pathname","detectedLocale","preferredDomain","detectDomainLocale","domains","isPDomain","domain","isPLocale","scheme","http","rlocale","formatUrl","basePath","trailingSlash"],"mappings":";;;;+BAqEgBA;;;eAAAA;;;8BAnE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AEA,MAAMe,kBAAkBC,IAAAA,sCAAkB,EACxCP,WAAWpB,IAAI,CAAC4B,OAAO,EACvBnB,WACAG;QAGF,IAAID,gBAAgBe,iBAAiB;YACnC,MAAMG,YAAYH,gBAAgBI,MAAM,KAAKnB,aAAamB,MAAM;YAChE,MAAMC,YAAYL,gBAAgBZ,aAAa,KAAKF;YACpD,IAAI,CAACiB,aAAa,CAACE,WAAW;gBAC5B,MAAMC,SAAS,AAAC,SAAMN,CAAAA,gBAAgBO,IAAI,GAAG,KAAK,GAAE;gBACpD,MAAMC,UAAUH,YAAY,KAAKnB;gBACjC,OAAO,AAAGoB,SAAO,QAAKN,gBAAgBI,MAAM,GAAC,MAAGI;YAClD;QACF;QAEA,IAAIT,eAAepB,WAAW,OAAOS,cAAcT,WAAW,IAAI;YAChE,OAAO8B,IAAAA,oBAAS,EAAC;gBACf,GAAGd,SAAS;gBACZG,UAAU,AAAGJ,CAAAA,WAAWgB,QAAQ,IAAI,EAAC,IAAE,MAAGX,iBACxCL,CAAAA,WAAWiB,aAAa,GAAG,MAAM,EAAC;YAEtC;QACF;IACF;AACF"}
|
||||
14
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.d.ts
generated
vendored
Normal file
14
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
export interface PathLocale {
|
||||
detectedLocale?: string;
|
||||
pathname: string;
|
||||
}
|
||||
/**
|
||||
* For a pathname that may include a locale from a list of locales, it
|
||||
* removes the locale from the pathname returning it alongside with the
|
||||
* detected locale.
|
||||
*
|
||||
* @param pathname A pathname that may include a locale.
|
||||
* @param locales A list of locales.
|
||||
* @returns The detected locale and pathname without locale
|
||||
*/
|
||||
export declare function normalizeLocalePath(pathname: string, locales?: string[]): PathLocale;
|
||||
30
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js
generated
vendored
Normal file
30
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "normalizeLocalePath", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return normalizeLocalePath;
|
||||
}
|
||||
});
|
||||
function normalizeLocalePath(pathname, locales) {
|
||||
let detectedLocale;
|
||||
// first item will be empty string from splitting at first char
|
||||
const pathnameParts = pathname.split("/");
|
||||
(locales || []).some((locale)=>{
|
||||
if (pathnameParts[1] && pathnameParts[1].toLowerCase() === locale.toLowerCase()) {
|
||||
detectedLocale = locale;
|
||||
pathnameParts.splice(1, 1);
|
||||
pathname = pathnameParts.join("/") || "/";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return {
|
||||
pathname,
|
||||
detectedLocale
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=normalize-locale-path.js.map
|
||||
1
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js.map
generated
vendored
Normal file
1
node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/normalize-locale-path.ts"],"names":["normalizeLocalePath","pathname","locales","detectedLocale","pathnameParts","split","some","locale","toLowerCase","splice","join"],"mappings":";;;;+BAcgBA;;;eAAAA;;;AAAT,SAASA,oBACdC,QAAgB,EAChBC,OAAkB;IAElB,IAAIC;IACJ,+DAA+D;IAC/D,MAAMC,gBAAgBH,SAASI,KAAK,CAAC;IAEnCH,CAAAA,WAAW,EAAE,AAAD,EAAGI,IAAI,CAAC,CAACC;QACrB,IACEH,aAAa,CAAC,EAAE,IAChBA,aAAa,CAAC,EAAE,CAACI,WAAW,OAAOD,OAAOC,WAAW,IACrD;YACAL,iBAAiBI;YACjBH,cAAcK,MAAM,CAAC,GAAG;YACxBR,WAAWG,cAAcM,IAAI,CAAC,QAAQ;YACtC,OAAO;QACT;QACA,OAAO;IACT;IAEA,OAAO;QACLT;QACAE;IACF;AACF"}
|
||||
Reference in New Issue
Block a user