astro-i18n-aut
Version:
The i18n integration for Astro 🧑🚀
2 lines • 8.82 kB
JavaScript
;var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var edge_runtime_exports={};__export(edge_runtime_exports,{BASE_URL:()=>BASE_URL,build:()=>build,defaultI18nConfig:()=>defaultI18nConfig,defaultLocale:()=>defaultLocale,filterCollectionByDefaultLocale:()=>filterCollectionByDefaultLocale,getAllLocaleUrls:()=>getAllLocaleUrls,getCollectionParamsSlug:()=>getCollectionParamsSlug,getLocale:()=>getLocale,getLocaleUrl:()=>getLocaleUrl,getLocaleUrlPrefix:()=>getLocaleUrlPrefix,getUrlWithoutLocale:()=>getUrlWithoutLocale,localeKeys:()=>localeKeys,locales:()=>locales,resolveTrailingSlash:()=>resolveTrailingSlash,trailingSlash:()=>trailingSlash});module.exports=__toCommonJS(edge_runtime_exports);var import_virtual_astro_i18n_aut=__toESM(require("virtual:astro-i18n-aut"),1),trailingSlash=import_virtual_astro_i18n_aut.default.trailingSlash,BASE_URL=import_virtual_astro_i18n_aut.default.BASE_URL?import_virtual_astro_i18n_aut.default.BASE_URL:"/",defaultLocale=import_virtual_astro_i18n_aut.default.defaultLocale,locales=import_virtual_astro_i18n_aut.default.locales,localeKeys=Object.keys(import_virtual_astro_i18n_aut.default.locales),redirectDefaultLocale=import_virtual_astro_i18n_aut.default.redirectDefaultLocale,build=import_virtual_astro_i18n_aut.default.build;function filterCollectionByDefaultLocale(entry){return!!(typeof entry=="object"&&entry!==null&&"slug"in entry&&typeof entry.slug=="string"&&entry.slug.startsWith(defaultLocale+"/"))}__name(filterCollectionByDefaultLocale,"filterCollectionByDefaultLocale");function getCollectionParamsSlug(entries){return entries.reduce((accumulator,entry)=>(typeof entry=="object"&&entry!==null&&"slug"in entry&&typeof entry.slug=="string"&&accumulator.push({params:{slug:entry.slug.replace(defaultLocale+"/","")}}),accumulator),[])}__name(getCollectionParamsSlug,"getCollectionParamsSlug");function resolveTrailingSlash(url){let pathName=typeof url=="string"?url:url.pathname;return trailingSlash==="always"?pathName.at(-1)!=="/"&&(pathName=pathName+"/"):trailingSlash==="never"&&pathName!=="/"&&pathName.at(-1)==="/"&&(pathName=pathName.slice(0,-1)),pathName}__name(resolveTrailingSlash,"resolveTrailingSlash");function removeTrailingSlash(url){return url.at(-1)==="/"?url.slice(0,-1):url}__name(removeTrailingSlash,"removeTrailingSlash");function removeHtmlExtension(url){return url.endsWith(".html")?url.slice(0,-5):url}__name(removeHtmlExtension,"removeHtmlExtension");function getAllLocaleUrls(url){let pathName=typeof url=="string"?url:url.pathname,pathNameWithoutHtmlExtension=removeHtmlExtension(pathName),baseUrlWithoutTrailingSlash=removeTrailingSlash(BASE_URL),pathNameWithoutBaseUrl=BASE_URL==="/"?pathNameWithoutHtmlExtension:pathNameWithoutHtmlExtension.replace(baseUrlWithoutTrailingSlash,""),possibleLocaleKey=pathNameWithoutBaseUrl.slice(1,3),pathNameWithoutBaseUrlStartsWithLocale=localeKeys.filter(key=>key!==defaultLocale).includes(possibleLocaleKey);return pathNameWithoutBaseUrl.length===3&&pathNameWithoutBaseUrlStartsWithLocale?{...localeKeys.reduce((record,locale)=>(record[locale]=resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+"/"),record),{}),[defaultLocale]:resolveTrailingSlash(BASE_URL)}:pathNameWithoutBaseUrl[0]==="/"&&pathNameWithoutBaseUrl[3]==="/"&&pathNameWithoutBaseUrlStartsWithLocale?{...localeKeys.reduce((record,locale)=>(record[locale]=resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+pathNameWithoutBaseUrl.slice(3)),record),{}),[defaultLocale]:resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl.slice(3))}:{...localeKeys.reduce((record,locale)=>(record[locale]=resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+pathNameWithoutBaseUrl),record),{}),[defaultLocale]:resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl)}}__name(getAllLocaleUrls,"getAllLocaleUrls");function getLocale(url){let pathName=typeof url=="string"?url:url.pathname,pathNameWithoutHtmlExtension=removeHtmlExtension(pathName),baseUrlWithoutTrailingSlash=removeTrailingSlash(BASE_URL),pathNameWithoutBaseUrl=BASE_URL==="/"?pathNameWithoutHtmlExtension:pathNameWithoutHtmlExtension.replace(baseUrlWithoutTrailingSlash,""),possibleLocaleKey=pathNameWithoutBaseUrl.slice(1,3),pathNameWithoutBaseUrlStartsWithLocale=localeKeys.filter(key=>key!==defaultLocale).includes(possibleLocaleKey);return pathNameWithoutBaseUrl.length===3&&pathNameWithoutBaseUrlStartsWithLocale||pathNameWithoutBaseUrl[0]==="/"&&pathNameWithoutBaseUrl[3]==="/"&&pathNameWithoutBaseUrlStartsWithLocale?possibleLocaleKey:defaultLocale}__name(getLocale,"getLocale");function getLocaleUrl(url,locale){let pathName=typeof url=="string"?url:url.pathname,pathNameWithoutHtmlExtension=removeHtmlExtension(pathName),baseUrlWithoutTrailingSlash=removeTrailingSlash(BASE_URL),pathNameWithoutBaseUrl=BASE_URL==="/"?pathNameWithoutHtmlExtension:pathNameWithoutHtmlExtension.replace(baseUrlWithoutTrailingSlash,""),possibleLocaleKey=pathNameWithoutBaseUrl.slice(1,3),pathNameWithoutBaseUrlStartsWithLocale=localeKeys.filter(key=>key!==defaultLocale).includes(possibleLocaleKey);return pathNameWithoutBaseUrl.length===3&&pathNameWithoutBaseUrlStartsWithLocale?locale===defaultLocale?resolveTrailingSlash(BASE_URL):resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+"/"):pathNameWithoutBaseUrl[0]==="/"&&pathNameWithoutBaseUrl[3]==="/"&&pathNameWithoutBaseUrlStartsWithLocale?locale===defaultLocale?resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl.slice(3)):resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+pathNameWithoutBaseUrl.slice(3)):locale===defaultLocale?resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl):resolveTrailingSlash(baseUrlWithoutTrailingSlash+"/"+locale+pathNameWithoutBaseUrl)}__name(getLocaleUrl,"getLocaleUrl");function getLocaleUrlPrefix(url){let pathName=typeof url=="string"?url:url.pathname,pathNameWithoutHtmlExtension=removeHtmlExtension(pathName),baseUrlWithoutTrailingSlash=removeTrailingSlash(BASE_URL),pathNameWithoutBaseUrl=BASE_URL==="/"?pathNameWithoutHtmlExtension:pathNameWithoutHtmlExtension.replace(baseUrlWithoutTrailingSlash,""),possibleLocaleKey=pathNameWithoutBaseUrl.slice(1,3),pathNameWithoutBaseUrlStartsWithLocale=localeKeys.filter(key=>key!==defaultLocale).includes(possibleLocaleKey);return pathNameWithoutBaseUrl.length===3&&pathNameWithoutBaseUrlStartsWithLocale||pathNameWithoutBaseUrl[0]==="/"&&pathNameWithoutBaseUrl[3]==="/"&&pathNameWithoutBaseUrlStartsWithLocale?"/"+possibleLocaleKey:""}__name(getLocaleUrlPrefix,"getLocaleUrlPrefix");function getUrlWithoutLocale(url){let pathName=typeof url=="string"?url:url.pathname,pathNameWithoutHtmlExtension=removeHtmlExtension(pathName),baseUrlWithoutTrailingSlash=removeTrailingSlash(BASE_URL),pathNameWithoutBaseUrl=BASE_URL==="/"?pathNameWithoutHtmlExtension:pathNameWithoutHtmlExtension.replace(baseUrlWithoutTrailingSlash,""),possibleLocaleKey=pathNameWithoutBaseUrl.slice(1,3),pathNameWithoutBaseUrlStartsWithLocale=localeKeys.filter(key=>key!==defaultLocale).includes(possibleLocaleKey);return pathNameWithoutBaseUrl.length===3&&pathNameWithoutBaseUrlStartsWithLocale?resolveTrailingSlash(BASE_URL):pathNameWithoutBaseUrl[0]==="/"&&pathNameWithoutBaseUrl[3]==="/"&&pathNameWithoutBaseUrlStartsWithLocale?resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl.slice(3)):resolveTrailingSlash(baseUrlWithoutTrailingSlash+pathNameWithoutBaseUrl)}__name(getUrlWithoutLocale,"getUrlWithoutLocale");var defaultI18nConfig={include:["pages/**/*"],exclude:["pages/api/**/*"],redirectDefaultLocale:308};0&&(module.exports={BASE_URL,build,defaultI18nConfig,defaultLocale,filterCollectionByDefaultLocale,getAllLocaleUrls,getCollectionParamsSlug,getLocale,getLocaleUrl,getLocaleUrlPrefix,getUrlWithoutLocale,localeKeys,locales,resolveTrailingSlash,trailingSlash});
//# sourceMappingURL=index.cjs.map