next-intl
Advanced tools
Comparing version
function getConfig() { | ||
throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl-docs.vercel.app/docs/getting-started/app-router"); | ||
throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router"); | ||
} | ||
export { getConfig as default }; |
@@ -78,3 +78,3 @@ import { normalizeTrailingSlash } from '../shared/utils.js'; | ||
// For domain-based routing there is no reasonable x-default | ||
!routing.domains && (routing.localePrefix.mode !== 'always' || normalizedUrl.pathname === '/'); | ||
!routing.domains || routing.domains.length === 0; | ||
if (shouldAddXDefault) { | ||
@@ -81,0 +81,0 @@ const url = new URL(getLocalizedPathname(normalizedUrl.pathname, routing.defaultLocale), normalizedUrl); |
@@ -1,2 +0,2 @@ | ||
import { NextResponse } from 'next/server.js'; | ||
import { NextResponse } from 'next/server'; | ||
import { receiveRoutingConfig } from '../routing/config.js'; | ||
@@ -3,0 +3,0 @@ import { HEADER_LOCALE_NAME } from '../shared/constants.js'; |
@@ -1,2 +0,2 @@ | ||
import { useRouter, usePathname } from 'next/navigation.js'; | ||
import { useRouter, usePathname } from 'next/navigation'; | ||
import { useMemo } from 'react'; | ||
@@ -17,5 +17,5 @@ import { useLocale } from 'use-intl'; | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#usepathname */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#usepathname */ | ||
function usePathname$1() { | ||
const pathname = useBasePathname(config.localePrefix); | ||
const pathname = useBasePathname(config); | ||
const locale = useLocale(); | ||
@@ -59,7 +59,7 @@ | ||
...router, | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
push: createHandler(router.push), | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
replace: createHandler(router.replace), | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
prefetch: createHandler(router.prefetch) | ||
@@ -66,0 +66,0 @@ }; |
@@ -1,7 +0,7 @@ | ||
import { usePathname } from 'next/navigation.js'; | ||
import { usePathname } from 'next/navigation'; | ||
import { useMemo } from 'react'; | ||
import { useLocale } from 'use-intl'; | ||
import { hasPathnamePrefixed, unprefixPathname, getLocalePrefix } from '../../shared/utils.js'; | ||
import { hasPathnamePrefixed, unprefixPathname, getLocalePrefix, getLocaleAsPrefix } from '../../shared/utils.js'; | ||
function useBasePathname(localePrefix) { | ||
function useBasePathname(config) { | ||
// The types aren't entirely correct here. Outside of Next.js | ||
@@ -20,9 +20,18 @@ // `useParams` can be called, but the return type is `null`. | ||
if (!pathname) return pathname; | ||
const prefix = getLocalePrefix(locale, localePrefix); | ||
let unlocalizedPathname = pathname; | ||
const prefix = getLocalePrefix(locale, config.localePrefix); | ||
const isPathnamePrefixed = hasPathnamePrefixed(prefix, pathname); | ||
const unlocalizedPathname = isPathnamePrefixed ? unprefixPathname(pathname, prefix) : pathname; | ||
if (isPathnamePrefixed) { | ||
unlocalizedPathname = unprefixPathname(pathname, prefix); | ||
} else if (config.localePrefix.mode === 'as-needed' && config.localePrefix.prefixes) { | ||
// Workaround for https://github.com/vercel/next.js/issues/73085 | ||
const localeAsPrefix = getLocaleAsPrefix(locale); | ||
if (hasPathnamePrefixed(localeAsPrefix, pathname)) { | ||
unlocalizedPathname = unprefixPathname(pathname, localeAsPrefix); | ||
} | ||
} | ||
return unlocalizedPathname; | ||
}, [locale, localePrefix, pathname]); | ||
}, [config.localePrefix, locale, pathname]); | ||
} | ||
export { useBasePathname as default }; |
"use client"; | ||
import NextLink from 'next/link.js'; | ||
import { usePathname } from 'next/navigation.js'; | ||
import NextLink from 'next/link'; | ||
import { usePathname } from 'next/navigation'; | ||
import { forwardRef, useState, useEffect } from 'react'; | ||
@@ -5,0 +5,0 @@ import { useLocale } from 'use-intl'; |
@@ -1,6 +0,6 @@ | ||
import { redirect, permanentRedirect } from 'next/navigation.js'; | ||
import { redirect, permanentRedirect } from 'next/navigation'; | ||
import { forwardRef } from 'react'; | ||
import { receiveRoutingConfig } from '../../routing/config.js'; | ||
import use from '../../shared/use.js'; | ||
import { isLocalizableHref } from '../../shared/utils.js'; | ||
import { isLocalizableHref, isPromise } from '../../shared/utils.js'; | ||
import BaseLink from './BaseLink.js'; | ||
@@ -44,3 +44,3 @@ import { validateReceivedConfig, serializeSearchParams, compileLocalizedPathname, applyPathnamePrefix, normalizeNameOrNameWithParams } from './utils.js'; | ||
const localePromiseOrValue = getLocale(); | ||
const curLocale = localePromiseOrValue instanceof Promise ? use(localePromiseOrValue) : localePromiseOrValue; | ||
const curLocale = isPromise(localePromiseOrValue) ? use(localePromiseOrValue) : localePromiseOrValue; | ||
const finalPathname = isLocalizable ? getPathname( | ||
@@ -120,3 +120,3 @@ // @ts-expect-error -- This is ok | ||
function getRedirectFn(fn) { | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#redirect */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#redirect */ | ||
return function redirectFn(args, ...rest) { | ||
@@ -123,0 +123,0 @@ return fn( |
@@ -136,3 +136,3 @@ import { getSortedPathnames, matchesPathname, isLocalizableHref, prefixPathname, getLocalePrefix, normalizeTrailingSlash } from '../../shared/utils.js'; | ||
if (!domain) { | ||
console.error("You're using a routing configuration with `localePrefix: 'as-needed'` in combination with `domains`. In order to compute a correct pathname, you need to provide a `domain` parameter.\n\nSee: https://next-intl-docs.vercel.app/docs/routing#domains-localeprefix-asneeded"); | ||
console.error("You're using a routing configuration with `localePrefix: 'as-needed'` in combination with `domains`. In order to compute a correct pathname, you need to provide a `domain` parameter.\n\nSee: https://next-intl.dev/docs/routing#domains-localeprefix-asneeded"); | ||
} | ||
@@ -139,0 +139,0 @@ } |
import fs from 'fs'; | ||
import path from 'path'; | ||
import { throwError } from './utils.js'; | ||
import watchFile from './watchFile.js'; | ||
@@ -12,22 +13,22 @@ function runOnce(fn) { | ||
} | ||
function createMessagesDeclaration(messagesPath) { | ||
const fullPath = path.resolve(messagesPath); | ||
if (!fs.existsSync(fullPath)) { | ||
throwError(`\`createMessagesDeclaration\` points to a non-existent file: ${fullPath}`); | ||
} | ||
if (!fullPath.endsWith('.json')) { | ||
throwError(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${fullPath}`); | ||
} | ||
const isDev = process.argv.includes('dev'); | ||
const isBuild = process.argv.includes('build'); | ||
if (!isDev && !isBuild) { | ||
return; | ||
} | ||
function createMessagesDeclaration(messagesPaths) { | ||
// Next.js can call the Next.js config multiple | ||
// times - ensure we only run once. | ||
runOnce(() => { | ||
compileDeclaration(messagesPath); | ||
if (isDev) { | ||
startWatching(messagesPath); | ||
for (const messagesPath of messagesPaths) { | ||
const fullPath = path.resolve(messagesPath); | ||
if (!fs.existsSync(fullPath)) { | ||
throwError(`\`createMessagesDeclaration\` points to a non-existent file: ${fullPath}`); | ||
} | ||
if (!fullPath.endsWith('.json')) { | ||
throwError(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${fullPath}`); | ||
} | ||
// Keep this as a runtime check and don't replace | ||
// this with a constant during the build process | ||
const env = process.env['NODE_ENV'.trim()]; | ||
compileDeclaration(messagesPath); | ||
if (env === 'development') { | ||
startWatching(messagesPath); | ||
} | ||
} | ||
@@ -37,6 +38,4 @@ }); | ||
function startWatching(messagesPath) { | ||
const watcher = fs.watch(messagesPath, eventType => { | ||
if (eventType === 'change') { | ||
compileDeclaration(messagesPath, true); | ||
} | ||
const watcher = watchFile(messagesPath, () => { | ||
compileDeclaration(messagesPath, true); | ||
}); | ||
@@ -51,3 +50,3 @@ process.on('exit', () => { | ||
return `// This file is auto-generated by next-intl, do not edit directly. | ||
// See: https://next-intl-docs.vercel.app/docs/workflows/typescript#messages-arguments | ||
// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments | ||
@@ -54,0 +53,0 @@ declare const messages: ${content.trim()}; |
@@ -7,6 +7,7 @@ import createMessagesDeclaration from './createMessagesDeclaration.js'; | ||
if (nextConfig?.i18n != null) { | ||
warn("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n"); | ||
warn("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n"); | ||
} | ||
if (pluginConfig.experimental?.createMessagesDeclaration) { | ||
createMessagesDeclaration(pluginConfig.experimental.createMessagesDeclaration); | ||
const messagesPathOrPaths = pluginConfig.experimental?.createMessagesDeclaration; | ||
if (messagesPathOrPaths) { | ||
createMessagesDeclaration(typeof messagesPathOrPaths === 'string' ? [messagesPathOrPaths] : messagesPathOrPaths); | ||
} | ||
@@ -13,0 +14,0 @@ return getNextConfig(pluginConfig, nextConfig); |
@@ -28,3 +28,3 @@ import { useTranslations as useTranslations$1, useFormatter as useFormatter$1 } from 'use-intl'; | ||
2) You intended to render this component on the client side, but no context was found. | ||
Learn more about this error here: https://next-intl-docs.vercel.app/docs/environments/server-client-components#missing-context` ); | ||
Learn more about this error here: https://next-intl.dev/docs/environments/server-client-components#missing-context` ); | ||
} | ||
@@ -31,0 +31,0 @@ }; |
@@ -6,2 +6,3 @@ import getConfigNow from '../server/react-server/getConfigNow.js'; | ||
import getLocaleCached from '../server/react-server/getLocale.js'; | ||
import getMessages from '../server/react-server/getMessages.js'; | ||
import getTimeZone from '../server/react-server/getTimeZone.js'; | ||
@@ -12,2 +13,3 @@ | ||
locale, | ||
messages, | ||
now, | ||
@@ -22,3 +24,4 @@ timeZone, | ||
formats: formats === undefined ? await getFormats() : formats, | ||
locale: locale ?? (await getLocaleCached()) | ||
locale: locale ?? (await getLocaleCached()), | ||
messages: messages === undefined ? await getMessages() : messages | ||
// Note that we don't assign a default for `now` here, | ||
@@ -25,0 +28,0 @@ // we only read one from the request config - if any. |
@@ -9,3 +9,3 @@ import getConfig from '../server/react-server/getConfig.js'; | ||
if (error instanceof TypeError && error.message.includes("Cannot read properties of null (reading 'use')")) { | ||
throw new Error(`\`${hookName}\` is not callable within an async component. Please refer to https://next-intl-docs.vercel.app/docs/environments/server-client-components#async-components`, { | ||
throw new Error(`\`${hookName}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`, { | ||
cause: error | ||
@@ -12,0 +12,0 @@ }); |
@@ -13,4 +13,2 @@ function receiveRoutingConfig(input) { | ||
name: 'NEXT_LOCALE', | ||
maxAge: 5 * 60 * 60, | ||
// 5 hours | ||
sameSite: 'lax', | ||
@@ -17,0 +15,0 @@ ...(typeof localeCookie === 'object' && localeCookie) |
@@ -1,7 +0,2 @@ | ||
import validateLocales from './validateLocales.js'; | ||
function defineRouting(config) { | ||
{ | ||
validateLocales(config.locales); | ||
} | ||
return config; | ||
@@ -8,0 +3,0 @@ } |
export { default as getRequestConfig } from './server/react-server/getRequestConfig.js'; | ||
export { default as getFormatter } from './server/react-server/getFormatter.js'; | ||
export { default as getNow } from './server/react-server/getNow.js'; | ||
export { default as getMessages } from './server/react-server/getMessages.js'; | ||
export { default as getTimeZone } from './server/react-server/getTimeZone.js'; | ||
export { default as getTranslations } from './server/react-server/getTranslations.js'; | ||
export { default as getMessages } from './server/react-server/getMessages.js'; | ||
export { default as getLocale } from './server/react-server/getLocale.js'; | ||
export { setCachedRequestLocale as setRequestLocale } from './server/react-server/RequestLocaleCache.js'; |
import { cache } from 'react'; | ||
import { _createIntlFormatters, _createCache, initializeConfig } from 'use-intl/core'; | ||
import { isPromise } from '../../shared/utils.js'; | ||
import { getRequestLocale } from './RequestLocale.js'; | ||
import getRuntimeConfig from 'next-intl/config'; | ||
import validateLocale from './validateLocale.js'; | ||
@@ -20,6 +22,7 @@ // This is automatically inherited by `NextIntlClientProvider` if | ||
See also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request | ||
See also: https://next-intl.dev/docs/usage/configuration#i18n-request | ||
`); | ||
} | ||
const params = { | ||
locale: localeOverride, | ||
// In case the consumer doesn't read `params.locale` and instead provides the | ||
@@ -33,8 +36,11 @@ // `locale` (either in a single-language workflow or because the locale is | ||
let result = getConfig(params); | ||
if (result instanceof Promise) { | ||
if (isPromise(result)) { | ||
result = await result; | ||
} | ||
if (!result.locale) { | ||
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request'); | ||
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request'); | ||
} | ||
{ | ||
validateLocale(result.locale); | ||
} | ||
return result; | ||
@@ -41,0 +47,0 @@ } |
import { cache } from 'react'; | ||
function defaultNow() { | ||
// See https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-server | ||
// See https://next-intl.dev/docs/usage/dates-times#relative-times-server | ||
return new Date(); | ||
@@ -6,0 +6,0 @@ } |
@@ -6,3 +6,3 @@ import { cache } from 'react'; | ||
if (!config.messages) { | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages'); | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages'); | ||
} | ||
@@ -9,0 +9,0 @@ return config.messages; |
@@ -6,6 +6,2 @@ import { cache } from 'react'; | ||
function getFormatterCachedImpl(config) { | ||
// same here? | ||
// also add a test | ||
// also for getTranslations/useTranslations | ||
// add a test with a getter maybe, don't mock | ||
return createFormatter({ | ||
@@ -12,0 +8,0 @@ ...config, |
@@ -9,7 +9,7 @@ import { cache } from 'react'; | ||
// CALL SIGNATURE 1: `getTranslations(namespace)` | ||
// Call signature 1: `getTranslations(namespace)` | ||
// CALL SIGNATURE 2: `getTranslations({locale, namespace})` | ||
// Call signature 2: `getTranslations({locale, namespace})` | ||
// IMPLEMENTATION | ||
// Implementation | ||
async function getTranslations(namespaceOrOpts) { | ||
@@ -16,0 +16,0 @@ let namespace; |
@@ -1,4 +0,5 @@ | ||
import { headers } from 'next/headers.js'; | ||
import { headers } from 'next/headers'; | ||
import { cache } from 'react'; | ||
import { HEADER_LOCALE_NAME } from '../../shared/constants.js'; | ||
import { isPromise } from '../../shared/utils.js'; | ||
import { getCachedRequestLocale } from './RequestLocaleCache.js'; | ||
@@ -10,3 +11,3 @@ | ||
// Compatibility with Next.js <15 | ||
return promiseOrValue instanceof Promise ? await promiseOrValue : promiseOrValue; | ||
return isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue; | ||
} | ||
@@ -20,3 +21,3 @@ const getHeaders = cache(getHeadersImpl); | ||
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') { | ||
const wrappedError = new Error('Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering', { | ||
const wrappedError = new Error('Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering', { | ||
cause: error | ||
@@ -23,0 +24,0 @@ }); |
@@ -10,3 +10,3 @@ "use client"; | ||
if (!locale) { | ||
throw new Error("Couldn't infer the `locale` prop in `NextIntlClientProvider`, please provide it explicitly.\n\nSee https://next-intl-docs.vercel.app/docs/configuration#locale" ); | ||
throw new Error("Couldn't infer the `locale` prop in `NextIntlClientProvider`, please provide it explicitly.\n\nSee https://next-intl.dev/docs/configuration#locale" ); | ||
} | ||
@@ -13,0 +13,0 @@ return /*#__PURE__*/jsx(IntlProvider, { |
@@ -64,4 +64,7 @@ function isRelativeHref(href) { | ||
// to decide to use it or not. | ||
'/' + locale; | ||
getLocaleAsPrefix(locale); | ||
} | ||
function getLocaleAsPrefix(locale) { | ||
return '/' + locale; | ||
} | ||
function templateToRegex(template) { | ||
@@ -123,3 +126,7 @@ const regexPattern = template | ||
} | ||
function isPromise(value) { | ||
// https://github.com/amannn/next-intl/issues/1711 | ||
return typeof value.then === 'function'; | ||
} | ||
export { getLocalePrefix, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname }; | ||
export { getLocaleAsPrefix, getLocalePrefix, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, isPromise, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname }; |
@@ -1,1 +0,1 @@ | ||
function t(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl-docs.vercel.app/docs/getting-started/app-router")}export{t as default}; | ||
function t(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router")}export{t as default}; |
@@ -1,1 +0,1 @@ | ||
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function m({localizedPathnames:m,request:p,resolvedLocale:s,routing:c}){const f=p.nextUrl.clone(),h=a(p.headers);function i(a,t){return a.pathname=e(a.pathname),p.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,p.nextUrl.basePath)),`<${a.toString()}>; rel="alternate"; hreflang="${t}"`}function u(e,a){return m&&"object"==typeof m?r(e,m[s],m[a]):e}h&&(f.port="",f.host=h),f.protocol=p.headers.get("x-forwarded-proto")??f.protocol,f.pathname=t(f.pathname,c.locales,c.localePrefix);const d=o(c.locales,c.localePrefix,!1).flatMap((([e,a])=>{function t(e){return"/"===e?a:a+e}let o;if(c.domains){return c.domains.filter((a=>n(e,a))).map((a=>(o=new URL(f),o.port="",o.host=a.domain,o.pathname=u(f.pathname,e),e===a.defaultLocale&&"always"!==c.localePrefix.mode||(o.pathname=t(o.pathname)),i(o,e))))}{let a;a=m&&"object"==typeof m?u(f.pathname,e):f.pathname,e===c.defaultLocale&&"always"!==c.localePrefix.mode||(a=t(a)),o=new URL(a,f)}return i(o,e)}));if(!c.domains&&("always"!==c.localePrefix.mode||"/"===f.pathname)){const e=new URL(u(f.pathname,c.defaultLocale),f);d.push(i(e,"x-default"))}return d.join(", ")}export{m as default}; | ||
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function s({localizedPathnames:s,request:m,resolvedLocale:p,routing:h}){const i=m.nextUrl.clone(),c=a(m.headers);function f(a,t){return a.pathname=e(a.pathname),m.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,m.nextUrl.basePath)),`<${a.toString()}>; rel="alternate"; hreflang="${t}"`}function u(e,a){return s&&"object"==typeof s?r(e,s[p],s[a]):e}c&&(i.port="",i.host=c),i.protocol=m.headers.get("x-forwarded-proto")??i.protocol,i.pathname=t(i.pathname,h.locales,h.localePrefix);const d=o(h.locales,h.localePrefix,!1).flatMap((([e,a])=>{function t(e){return"/"===e?a:a+e}let o;if(h.domains){return h.domains.filter((a=>n(e,a))).map((a=>(o=new URL(i),o.port="",o.host=a.domain,o.pathname=u(i.pathname,e),e===a.defaultLocale&&"always"!==h.localePrefix.mode||(o.pathname=t(o.pathname)),f(o,e))))}{let a;a=s&&"object"==typeof s?u(i.pathname,e):i.pathname,e===h.defaultLocale&&"always"!==h.localePrefix.mode||(a=t(a)),o=new URL(a,i)}return f(o,e)}));if(!h.domains||0===h.domains.length){const e=new URL(u(i.pathname,h.defaultLocale),i);d.push(f(e,"x-default"))}return d.join(", ")}export{s as default}; |
@@ -1,1 +0,1 @@ | ||
import{NextResponse as e}from"next/server.js";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as o,normalizeTrailingSlash as a,getLocalePrefix as l}from"../shared/utils.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as p,getBestMatchingDomain as u,applyBasePath as U,getLocaleAsPrefix as P}from"./utils.js";function g(g){const v=t(g);return function(t){let g;try{g=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const L=c(g),{domain:j,locale:w}=s(v,t.headers,t.cookies,L),k=j?j.defaultLocale===w:w===v.defaultLocale,b=v.domains?.filter((e=>d(w,e)))||[],y=null!=v.domains&&!j;function R(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=U(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,w),e.rewrite(a,{request:{headers:l}})}function q(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),b.length>0&&!o&&j){const e=u(j,w,b);e&&(o=e.domain,e.defaultLocale===w&&"as-needed"===v.localePrefix.mode&&(l.pathname=f(l.pathname,v.locales,v.localePrefix)))}return o&&(l.host=o,t.headers.get("x-forwarded-host")&&(l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol,l.port=t.headers.get("x-forwarded-port")??"")),t.nextUrl.basePath&&(l.pathname=U(l.pathname,t.nextUrl.basePath)),e.redirect(l.toString())}const H=f(L,v.locales,v.localePrefix),z=m(L,v.locales,v.localePrefix),A=null!=z,C="never"===v.localePrefix.mode||k&&"as-needed"===v.localePrefix.mode;let I,S,V=H;const B=v.pathnames;if(B){let e;if([e,S]=h(B,H,w),S){const r=B[S],a="string"==typeof r?r:r[w];if(o(a,H))V=x(H,a,S);else{let o;o=e?"string"==typeof r?r:r[e]:S;const n=C?void 0:l(w,v.localePrefix),s=x(H,o,a);I=q(p(s,n,t.nextUrl.search))}}}if(!I)if("/"!==V||A){const e=p(V,P(w),t.nextUrl.search);if(A){const r=p(H,z.prefix,t.nextUrl.search);if("never"===v.localePrefix.mode)I=q(p(H,void 0,t.nextUrl.search));else if(z.exact)if(k&&C)I=q(p(H,void 0,t.nextUrl.search));else if(v.domains){const t=u(j,z.locale,b);I=j?.domain===t?.domain||y?R(e):q(r,t?.domain)}else I=R(e);else I=q(r)}else I=C?R(e):q(p(H,l(w,v.localePrefix),t.nextUrl.search))}else I=C?R(p(V,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default}; | ||
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as o,normalizeTrailingSlash as a,getLocalePrefix as l}from"../shared/utils.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as p,getBestMatchingDomain as u,applyBasePath as U,getLocaleAsPrefix as P}from"./utils.js";function g(g){const v=t(g);return function(t){let g;try{g=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const L=c(g),{domain:j,locale:w}=s(v,t.headers,t.cookies,L),k=j?j.defaultLocale===w:w===v.defaultLocale,b=v.domains?.filter((e=>d(w,e)))||[],y=null!=v.domains&&!j;function R(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=U(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,w),e.rewrite(a,{request:{headers:l}})}function q(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),b.length>0&&!o&&j){const e=u(j,w,b);e&&(o=e.domain,e.defaultLocale===w&&"as-needed"===v.localePrefix.mode&&(l.pathname=f(l.pathname,v.locales,v.localePrefix)))}return o&&(l.host=o,t.headers.get("x-forwarded-host")&&(l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol,l.port=t.headers.get("x-forwarded-port")??"")),t.nextUrl.basePath&&(l.pathname=U(l.pathname,t.nextUrl.basePath)),e.redirect(l.toString())}const H=f(L,v.locales,v.localePrefix),z=m(L,v.locales,v.localePrefix),A=null!=z,C="never"===v.localePrefix.mode||k&&"as-needed"===v.localePrefix.mode;let I,S,V=H;const B=v.pathnames;if(B){let e;if([e,S]=h(B,H,w),S){const r=B[S],a="string"==typeof r?r:r[w];if(o(a,H))V=x(H,a,S);else{let o;o=e?"string"==typeof r?r:r[e]:S;const n=C?void 0:l(w,v.localePrefix),s=x(H,o,a);I=q(p(s,n,t.nextUrl.search))}}}if(!I)if("/"!==V||A){const e=p(V,P(w),t.nextUrl.search);if(A){const r=p(H,z.prefix,t.nextUrl.search);if("never"===v.localePrefix.mode)I=q(p(H,void 0,t.nextUrl.search));else if(z.exact)if(k&&C)I=q(p(H,void 0,t.nextUrl.search));else if(v.domains){const t=u(j,z.locale,b);I=j?.domain===t?.domain||y?R(e):q(r,t?.domain)}else I=R(e);else I=q(r)}else I=C?R(e):q(p(H,l(w,v.localePrefix),t.nextUrl.search))}else I=C?R(p(V,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default}; |
@@ -1,1 +0,1 @@ | ||
import{useRouter as e,usePathname as t}from"next/navigation.js";import{useMemo as o}from"react";import{useLocale as n}from"use-intl";import r from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import i from"./useBasePathname.js";function c(c){const{Link:m,config:u,getPathname:f,...h}=r(n,c);return{...h,Link:m,usePathname:function(){const e=i(u.localePrefix),t=n();return o((()=>e&&u.pathnames?s(t,e,u.pathnames):e),[t,e])},useRouter:function(){const r=e(),s=n(),i=t();return o((()=>{function e(e){return function(t,o){const{locale:n,...r}=o||{},c=[f({href:t,locale:n||s,domain:window.location.host})];Object.keys(r).length>0&&c.push(r),e(...c),a(u.localeCookie,i,s,n)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[s,i,r])},getPathname:f}}export{c as default}; | ||
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as o}from"react";import{useLocale as n}from"use-intl";import r from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import i from"./useBasePathname.js";function c(c){const{Link:m,config:u,getPathname:h,...f}=r(n,c);return{...f,Link:m,usePathname:function(){const e=i(u),t=n();return o((()=>e&&u.pathnames?s(t,e,u.pathnames):e),[t,e])},useRouter:function(){const r=e(),s=n(),i=t();return o((()=>{function e(e){return function(t,o){const{locale:n,...r}=o||{},c=[h({href:t,locale:n||s,domain:window.location.host})];Object.keys(r).length>0&&c.push(r),e(...c),a(u.localeCookie,i,s,n)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[s,i,r])},getPathname:h}}export{c as default}; |
@@ -1,1 +0,1 @@ | ||
import{usePathname as r}from"next/navigation.js";import{useMemo as t}from"react";import{useLocale as o}from"use-intl";import{hasPathnamePrefixed as n,unprefixPathname as i,getLocalePrefix as e}from"../../shared/utils.js";function m(m){const s=r(),f=o();return t((()=>{if(!s)return s;const r=e(f,m);return n(r,s)?i(s,r):s}),[f,m,s])}export{m as default}; | ||
import{usePathname as e}from"next/navigation";import{useMemo as r}from"react";import{useLocale as o}from"use-intl";import{hasPathnamePrefixed as t,unprefixPathname as i,getLocalePrefix as f,getLocaleAsPrefix as l}from"../../shared/utils.js";function n(n){const s=e(),a=o();return r((()=>{if(!s)return s;let e=s;const r=f(a,n.localePrefix);if(t(r,s))e=i(s,r);else if("as-needed"===n.localePrefix.mode&&n.localePrefix.prefixes){const r=l(a);t(r,s)&&(e=i(s,r))}return e}),[n.localePrefix,a,s])}export{n as default}; |
"use client"; | ||
import o from"next/link.js";import{usePathname as e}from"next/navigation.js";import{forwardRef as n,useState as t,useEffect as r}from"react";import{useLocale as i}from"use-intl";import c from"./syncLocaleCookie.js";import{jsx as a}from"react/jsx-runtime";function f({defaultLocale:n,href:f,locale:l,localeCookie:m,onClick:s,prefetch:u,unprefixed:p,...d},h){const k=i(),j=null!=l&&l!==k,x=l||k,C=function(){const[o,e]=t();return r((()=>{e(window.location.host)}),[]),o}(),v=C&&p&&(p.domains[C]===x||!Object.keys(p.domains).includes(C)&&k===n&&!l)?p.pathname:f,L=e();j&&(u=!1);return a(o,{ref:h,href:v,hrefLang:j?l:void 0,onClick:function(o){c(m,L,k,l),s&&s(o)},prefetch:u,...d})}var l=n(f);export{l as default}; | ||
import o from"next/link";import{usePathname as e}from"next/navigation";import{forwardRef as n,useState as t,useEffect as r}from"react";import{useLocale as i}from"use-intl";import c from"./syncLocaleCookie.js";import{jsx as a}from"react/jsx-runtime";function f({defaultLocale:n,href:f,locale:l,localeCookie:m,onClick:s,prefetch:u,unprefixed:p,...d},h){const k=i(),j=null!=l&&l!==k,x=l||k,C=function(){const[o,e]=t();return r((()=>{e(window.location.host)}),[]),o}(),v=C&&p&&(p.domains[C]===x||!Object.keys(p.domains).includes(C)&&k===n&&!l)?p.pathname:f,L=e();j&&(u=!1);return a(o,{ref:h,href:v,hrefLang:j?l:void 0,onClick:function(o){c(m,L,k,l),s&&s(o)},prefetch:u,...d})}var l=n(f);export{l as default}; |
@@ -1,1 +0,1 @@ | ||
import{redirect as e,permanentRedirect as o}from"next/navigation.js";import{forwardRef as a}from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as r}from"../../shared/utils.js";import i from"./BaseLink.js";import{serializeSearchParams as m,compileLocalizedPathname as l,applyPathnamePrefix as c,normalizeNameOrNameWithParams as f}from"./utils.js";import{jsx as s}from"react/jsx-runtime";function u(u,p){const d=t(p||{}),h=d.pathnames,j="as-needed"===d.localePrefix.mode&&d.domains||void 0;function g({href:e,locale:o,...a},t){let m,l;"object"==typeof e?(m=e.pathname,l=e.params):m=e;const c=r(e),f=u(),p=f instanceof Promise?n(f):f,g=c?x({locale:o||p,href:null==h?m:{pathname:m,params:l}},null!=o||j||void 0):m;return s(i,{ref:t,defaultLocale:d.defaultLocale,href:"object"==typeof e?{...e,pathname:g}:g,locale:o,localeCookie:d.localeCookie,unprefixed:j&&c?{domains:d.domains.reduce(((e,o)=>(e[o.domain]=o.defaultLocale,e)),{}),pathname:x({locale:p,href:null==h?m:{pathname:m,params:l}},!1)}:void 0,...a})}const v=a(g);function x(e,o){const{href:a,locale:t}=e;let n;return null==h?"object"==typeof a?(n=a.pathname,a.query&&(n+=m(a.query))):n=a:n=l({locale:t,...f(a),pathnames:d.pathnames}),c(n,t,d,e.domain,o)}function y(e){return function(o,...a){return e(x(o,o.domain?void 0:j),...a)}}const L=y(e),k=y(o);return{config:d,Link:v,redirect:L,permanentRedirect:k,getPathname:x}}export{u as default}; | ||
import{redirect as e,permanentRedirect as o}from"next/navigation";import{forwardRef as a}from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as r,isPromise as i}from"../../shared/utils.js";import m from"./BaseLink.js";import{serializeSearchParams as l,compileLocalizedPathname as c,applyPathnamePrefix as f,normalizeNameOrNameWithParams as s}from"./utils.js";import{jsx as u}from"react/jsx-runtime";function p(p,d){const h=t(d||{}),j=h.pathnames,g="as-needed"===h.localePrefix.mode&&h.domains||void 0;function v({href:e,locale:o,...a},t){let l,c;"object"==typeof e?(l=e.pathname,c=e.params):l=e;const f=r(e),s=p(),d=i(s)?n(s):s,v=f?y({locale:o||d,href:null==j?l:{pathname:l,params:c}},null!=o||g||void 0):l;return u(m,{ref:t,defaultLocale:h.defaultLocale,href:"object"==typeof e?{...e,pathname:v}:v,locale:o,localeCookie:h.localeCookie,unprefixed:g&&f?{domains:h.domains.reduce(((e,o)=>(e[o.domain]=o.defaultLocale,e)),{}),pathname:y({locale:d,href:null==j?l:{pathname:l,params:c}},!1)}:void 0,...a})}const x=a(v);function y(e,o){const{href:a,locale:t}=e;let n;return null==j?"object"==typeof a?(n=a.pathname,a.query&&(n+=l(a.query))):n=a:n=c({locale:t,...s(a),pathnames:h.pathnames}),f(n,t,h,e.domain,o)}function L(e){return function(o,...a){return e(y(o,o.domain?void 0:g),...a)}}const k=L(e),b=L(o);return{config:h,Link:x,redirect:k,permanentRedirect:b,getPathname:y}}export{p as default}; |
@@ -1,1 +0,1 @@ | ||
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";function n(n){const i=s.resolve(n);e.existsSync(i)||t(`\`createMessagesDeclaration\` points to a non-existent file: ${i}`),i.endsWith(".json")||t(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${i}`);const r=process.argv.includes("dev"),c=process.argv.includes("build");var a;(r||c)&&(a=()=>{o(n),r&&function(s){const t=e.watch(s,(e=>{"change"===e&&o(s,!0)}));process.on("exit",(()=>{t.close()}))}(n)},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",a()))}function o(s,t=!1){const n=s.replace(/\.json$/,".d.json.ts");function o(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl-docs.vercel.app/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(t)return e.promises.readFile(s,"utf-8").then((s=>e.promises.writeFile(n,o(s))));const i=e.readFileSync(s,"utf-8");e.writeFileSync(n,o(i))}export{n as default}; | ||
import e from"fs";import t from"path";import{throwError as s}from"./utils.js";import o from"./watchFile.js";function n(o){var n;n=()=>{for(const n of o){const o=t.resolve(n);e.existsSync(o)||s(`\`createMessagesDeclaration\` points to a non-existent file: ${o}`),o.endsWith(".json")||s(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${o}`);const c=process.env["NODE_ENV".trim()];r(n),"development"===c&&i(n)}},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",n())}function i(e){const t=o(e,(()=>{r(e,!0)}));process.on("exit",(()=>{t.close()}))}function r(t,s=!1){const o=t.replace(/\.json$/,".d.json.ts");function n(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(s)return e.promises.readFile(t,"utf-8").then((t=>e.promises.writeFile(o,n(t))));const i=e.readFileSync(t,"utf-8");e.writeFileSync(o,n(i))}export{n as default}; |
@@ -1,1 +0,1 @@ | ||
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";function n(n={}){const o="string"==typeof n?{requestConfig:n}:n;return function(n){return function(n,o){return null!=o?.i18n&&r("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n"),n.experimental?.createMessagesDeclaration&&e(n.experimental.createMessagesDeclaration),t(n,o)}(o,n)}}export{n as default}; | ||
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as n}from"./utils.js";function r(r={}){const o="string"==typeof r?{requestConfig:r}:r;return function(r){return function(r,o){null!=o?.i18n&&n("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");const i=r.experimental?.createMessagesDeclaration;return i&&e("string"==typeof i?[i]:i),t(r,o)}(o,r)}}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
import r from"../server/react-server/getConfigNow.js";import e from"../server/react-server/getFormats.js";import t from"../shared/NextIntlClientProvider.js";import{jsx as o}from"react/jsx-runtime";import a from"../server/react-server/getLocale.js";import s from"../server/react-server/getTimeZone.js";async function i({formats:i,locale:m,now:n,timeZone:f,...c}){return o(t,{formats:void 0===i?await e():i,locale:m??await a(),now:n??await r(),timeZone:f??await s(),...c})}export{i as default}; | ||
import e from"../server/react-server/getConfigNow.js";import r from"../server/react-server/getFormats.js";import t from"../shared/NextIntlClientProvider.js";import{jsx as o}from"react/jsx-runtime";import s from"../server/react-server/getLocale.js";import a from"../server/react-server/getMessages.js";import m from"../server/react-server/getTimeZone.js";async function i({formats:i,locale:n,messages:v,now:f,timeZone:c,...g}){return o(t,{formats:void 0===i?await r():i,locale:n??await s(),messages:void 0===v?await a():v,now:f??await e(),timeZone:c??await m(),...g})}export{i as default}; |
@@ -1,1 +0,1 @@ | ||
import e from"../server/react-server/getConfig.js";import r from"../shared/use.js";function n(n){return function(e,n){try{return r(n)}catch(r){throw r instanceof TypeError&&r.message.includes("Cannot read properties of null (reading 'use')")?new Error(`\`${e}\` is not callable within an async component. Please refer to https://next-intl-docs.vercel.app/docs/environments/server-client-components#async-components`,{cause:r}):r}}(n,e())}export{n as default}; | ||
import e from"../server/react-server/getConfig.js";import n from"../shared/use.js";function r(r){return function(e,r){try{return n(r)}catch(n){throw n instanceof TypeError&&n.message.includes("Cannot read properties of null (reading 'use')")?new Error(`\`${e}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`,{cause:n}):n}}(r,e())}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
function e(e){return{...e,localePrefix:(a=e.localePrefix,"object"==typeof a?a:{mode:a||"always"}),localeCookie:(o=e.localeCookie,!!(o??1)&&{name:"NEXT_LOCALE",maxAge:18e3,sameSite:"lax",..."object"==typeof o&&o}),localeDetection:e.localeDetection??!0,alternateLinks:e.alternateLinks??!0};var o,a}export{e as receiveRoutingConfig}; | ||
function e(e){return{...e,localePrefix:(a=e.localePrefix,"object"==typeof a?a:{mode:a||"always"}),localeCookie:(o=e.localeCookie,!!(o??1)&&{name:"NEXT_LOCALE",sameSite:"lax",..."object"==typeof o&&o}),localeDetection:e.localeDetection??!0,alternateLinks:e.alternateLinks??!0};var o,a}export{e as receiveRoutingConfig}; |
@@ -1,1 +0,1 @@ | ||
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getNow}from"./server/react-server/getNow.js";export{default as getMessages}from"./server/react-server/getMessages.js";export{default as getTimeZone}from"./server/react-server/getTimeZone.js";export{default as getTranslations}from"./server/react-server/getTranslations.js";export{default as getLocale}from"./server/react-server/getLocale.js";export{setCachedRequestLocale as setRequestLocale}from"./server/react-server/RequestLocaleCache.js"; | ||
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getNow}from"./server/react-server/getNow.js";export{default as getTimeZone}from"./server/react-server/getTimeZone.js";export{default as getTranslations}from"./server/react-server/getTranslations.js";export{default as getMessages}from"./server/react-server/getMessages.js";export{default as getLocale}from"./server/react-server/getLocale.js";export{setCachedRequestLocale as setRequestLocale}from"./server/react-server/RequestLocaleCache.js"; |
@@ -1,1 +0,1 @@ | ||
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import i from"next-intl/config";const s=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const a=e((async function(e,t){let o=e({get requestLocale(){return t?Promise.resolve(t):r()}});if(o instanceof Promise&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request");return o})),c=e(t),m=e(o);const u=e((async function(e){const t=await a(i,e);return{...n(t),_formatters:c(m()),timeZone:t.timeZone||s()}}));export{u as default}; | ||
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as r}from"use-intl/core";import{isPromise as n}from"../../shared/utils.js";import{getRequestLocale as i}from"./RequestLocale.js";import s from"next-intl/config";const a=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const c=e((async function(e,t){let o=e({locale:t,get requestLocale(){return t?Promise.resolve(t):i()}});if(n(o)&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request");return o})),m=e(t),l=e(o);const u=e((async function(e){const t=await c(s,e);return{...r(t),_formatters:m(l()),timeZone:t.timeZone||a()}}));export{u as default}; |
@@ -1,1 +0,1 @@ | ||
import{cache as e}from"react";import o from"./getConfig.js";function t(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return e.messages}const r=e((async function(e){return t(await o(e))}));async function n(e){return r(e?.locale)}export{n as default,t as getMessagesFromConfig}; | ||
import{cache as e}from"react";import t from"./getConfig.js";function o(e){if(!e.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages");return e.messages}const n=e((async function(e){return o(await t(e))}));async function r(e){return n(e?.locale)}export{r as default,o as getMessagesFromConfig}; |
@@ -1,1 +0,1 @@ | ||
import{headers as t}from"next/headers.js";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{getCachedRequestLocale as r}from"./RequestLocaleCache.js";const o=e((async function(){const e=t();return e instanceof Promise?await e:e}));const s=e((async function(){let t;try{t=(await o()).get(n)||void 0}catch(t){if(t instanceof Error&&"DYNAMIC_SERVER_USAGE"===t.digest){const e=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function i(){return r()||await s()}export{i as getRequestLocale}; | ||
import{headers as t}from"next/headers";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{isPromise as r}from"../../shared/utils.js";import{getCachedRequestLocale as o}from"./RequestLocaleCache.js";const s=e((async function(){const e=t();return r(e)?await e:e}));const i=e((async function(){let t;try{t=(await s()).get(n)||void 0}catch(t){if(t instanceof Error&&"DYNAMIC_SERVER_USAGE"===t.digest){const e=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function a(){return o()||await i()}export{a as getRequestLocale}; |
@@ -1,1 +0,1 @@ | ||
function t(t){return function(t){return"object"==typeof t?null==t.host&&null==t.hostname:!/^[a-z]+:/i.test(t)}(t)&&!function(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}(t)}function n(t,n){return t.replace(new RegExp(`^${n}`),"")||"/"}function e(t,n){let e=t;return/^\/(\?.*)?$/.test(n)&&(n=n.slice(1)),e+=n,e}function r(t,n){return n===t||n.startsWith(`${t}/`)}function u(t){const n=function(){try{return"true"===process.env._next_intl_trailing_slash}catch{return!1}}();if("/"!==t){const e=t.endsWith("/");n&&!e?t+="/":!n&&e&&(t=t.slice(0,-1))}return t}function i(t,n){const e=u(t),r=u(n);return o(e).test(r)}function c(t,n){return"never"!==n.mode&&n.prefixes?.[t]||"/"+t}function o(t){const n=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp(`^${n}$`)}function f(t){return t.includes("[[...")}function s(t){return t.includes("[...")}function l(t){return t.includes("[")}function a(t,n){const e=t.split("/"),r=n.split("/"),u=Math.max(e.length,r.length);for(let t=0;t<u;t++){const n=e[t],u=r[t];if(!n&&u)return-1;if(n&&!u)return 1;if(n||u){if(!l(n)&&l(u))return-1;if(l(n)&&!l(u))return 1;if(!s(n)&&s(u))return-1;if(s(n)&&!s(u))return 1;if(!f(n)&&f(u))return-1;if(f(n)&&!f(u))return 1}}return 0}function p(t){return t.sort(a)}export{c as getLocalePrefix,p as getSortedPathnames,r as hasPathnamePrefixed,t as isLocalizableHref,i as matchesPathname,u as normalizeTrailingSlash,e as prefixPathname,o as templateToRegex,n as unprefixPathname}; | ||
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(n,t){return n.replace(new RegExp(`^${t}`),"")||"/"}function e(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function r(n,t){return t===n||t.startsWith(`${n}/`)}function u(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch{return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function i(n,t){const e=u(n),r=u(t);return f(e).test(r)}function c(n,t){return"never"!==t.mode&&t.prefixes?.[n]||o(n)}function o(n){return"/"+n}function f(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp(`^${t}$`)}function s(n){return n.includes("[[...")}function l(n){return n.includes("[...")}function a(n){return n.includes("[")}function p(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!l(t)&&l(u))return-1;if(l(t)&&!l(u))return 1;if(!s(t)&&s(u))return-1;if(s(t)&&!s(u))return 1}}return 0}function h(n){return n.sort(p)}function g(n){return"function"==typeof n.then}export{o as getLocaleAsPrefix,c as getLocalePrefix,h as getSortedPathnames,r as hasPathnamePrefixed,n as isLocalizableHref,g as isPromise,i as matchesPathname,u as normalizeTrailingSlash,e as prefixPathname,f as templateToRegex,t as unprefixPathname}; |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export * from './react-client/index.tsx'; | ||
export * from './react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './react-server/index.tsx'; | ||
export * from './react-server/index.js'; |
@@ -1,1 +0,1 @@ | ||
export { default } from './middleware/index.tsx'; | ||
export { default } from './middleware/index.js'; |
import type { NextRequest } from 'next/server.js'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
/** | ||
@@ -5,0 +5,0 @@ * See https://developers.google.com/search/docs/specialty/international/localized-versions |
/** | ||
* The middleware, available as `next-intl/middleware`. | ||
*/ | ||
export { default } from './middleware.tsx'; | ||
export { default } from './middleware.js'; |
import { type NextRequest, NextResponse } from 'next/server.js'; | ||
import { type RoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import { type RoutingConfig } from '../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export default function createMiddleware<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): (request: NextRequest) => NextResponse<unknown>; |
import type { RequestCookies } from 'next/dist/server/web/spec-extension/cookies.js'; | ||
import type { Locale } from 'use-intl'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: Locale): string | undefined; | ||
@@ -6,0 +6,0 @@ export default function resolveLocale<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(routing: Omit<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'pathnames'>, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): { |
import type { NextRequest, NextResponse } from 'next/server.js'; | ||
import type { Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig, ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { InitializedLocaleCookieConfig, ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export default function syncCookie<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(request: NextRequest, response: NextResponse, locale: Locale, routing: Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'locales' | 'defaultLocale'> & { | ||
localeCookie: InitializedLocaleCookieConfig; | ||
}, domain?: DomainConfig<AppLocales>): void; |
import type { Locale } from 'use-intl'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export declare function getFirstPathnameSegment(pathname: string): string; | ||
@@ -4,0 +4,0 @@ export declare function getInternalTemplate<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(pathnames: AppPathnames, pathname: string, locale: AppLocales[number]): [AppLocales[number] | undefined, keyof AppPathnames | undefined]; |
@@ -1,1 +0,1 @@ | ||
export * from './navigation/react-client/index.tsx'; | ||
export * from './navigation/react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './navigation/react-server/index.tsx'; | ||
export * from './navigation/react-server/index.js'; |
import { type Locale } from 'use-intl'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
export default function createNavigation<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing?: [AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): { | ||
@@ -304,6 +304,6 @@ Link: import("react").ForwardRefExoticComponent<Omit<{ | ||
pathname: T; | ||
params?: import("../shared/StrictParams.tsx").default<T> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("../shared/StrictParams.tsx").default<T>; | ||
params: import("../shared/StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -315,21 +315,21 @@ pathname: T; | ||
useRouter: () => { | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
push: (href: Parameters<(args: { | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -342,21 +342,21 @@ locale: Locale; | ||
}) | undefined) => void; | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
replace: (href: Parameters<(args: { | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -369,21 +369,21 @@ locale: Locale; | ||
}) | undefined) => void; | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#userouter */ | ||
prefetch: (href: Parameters<(args: { | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -403,17 +403,17 @@ locale: Locale; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -427,17 +427,17 @@ locale: Locale; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -453,17 +453,17 @@ locale: Locale; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -470,0 +470,0 @@ locale: Locale; |
@@ -1,2 +0,2 @@ | ||
export { default as createNavigation } from './createNavigation.tsx'; | ||
export type { QueryParams } from '../shared/utils.tsx'; | ||
export { default as createNavigation } from './createNavigation.js'; | ||
export type { QueryParams } from '../shared/utils.js'; |
@@ -1,2 +0,5 @@ | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../../routing/types.tsx'; | ||
export default function useBasePathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): string | null; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../../routing/types.js'; | ||
export default function useBasePathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(config: { | ||
localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>; | ||
defaultLocale?: AppLocales[number]; | ||
}): string | null; |
@@ -1,3 +0,3 @@ | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
export default function createNavigation<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing?: [AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): { | ||
@@ -305,6 +305,6 @@ usePathname: () => never; | ||
pathname: T; | ||
params?: import("../shared/StrictParams.tsx").default<T> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("../shared/StrictParams.tsx").default<T>; | ||
params: import("../shared/StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -317,17 +317,17 @@ pathname: T; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -343,17 +343,17 @@ locale: import("use-intl").Locale; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -369,17 +369,17 @@ locale: import("use-intl").Locale; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
@@ -386,0 +386,0 @@ locale: import("use-intl").Locale; |
@@ -1,2 +0,2 @@ | ||
export { default as createNavigation } from './createNavigation.tsx'; | ||
export type { Pathnames } from '../../routing/types.tsx'; | ||
export { default as createNavigation } from './createNavigation.js'; | ||
export type { Pathnames } from '../../routing/types.js'; |
import { type LinkProps } from 'next/link.js'; | ||
import { type ComponentProps } from 'react'; | ||
import { type Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.tsx'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.js'; | ||
type NextLinkProps = Omit<ComponentProps<'a'>, keyof LinkProps> & Omit<LinkProps, 'locale'>; | ||
@@ -6,0 +6,0 @@ type Props = NextLinkProps & { |
import type { Locale } from 'use-intl'; | ||
import { type RoutingConfigLocalizedNavigation, type RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import { type HrefOrHrefWithParams, type QueryParams } from './utils.tsx'; | ||
import { type RoutingConfigLocalizedNavigation, type RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
import { type HrefOrHrefWithParams, type QueryParams } from './utils.js'; | ||
type PromiseOrValue<Type> = Type | Promise<Type>; | ||
@@ -20,3 +20,3 @@ /** | ||
}; | ||
localeCookie: import("../../routing/config.tsx").InitializedLocaleCookieConfig; | ||
localeCookie: import("../../routing/config.js").InitializedLocaleCookieConfig; | ||
localeDetection: NonNullable<boolean | undefined>; | ||
@@ -324,6 +324,6 @@ alternateLinks: NonNullable<boolean | undefined>; | ||
pathname: T; | ||
params?: import("./StrictParams.tsx").default<T> | undefined; | ||
params?: import("./StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("./StrictParams.tsx").default<T>; | ||
params: import("./StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -334,3 +334,3 @@ pathname: T; | ||
redirect: (args: Omit<Parameters<(args: { | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */ | ||
href: [AppPathnames] extends [never] ? string | { | ||
@@ -344,3 +344,3 @@ pathname: string; | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
@@ -351,3 +351,3 @@ domain: AppDomains[number]["domain"]; | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
@@ -357,3 +357,3 @@ domain: AppDomains[number]["domain"]; | ||
permanentRedirect: (args: Omit<Parameters<(args: { | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */ | ||
href: [AppPathnames] extends [never] ? string | { | ||
@@ -367,3 +367,3 @@ pathname: string; | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
@@ -374,3 +374,3 @@ domain: AppDomains[number]["domain"]; | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
@@ -380,3 +380,3 @@ domain: AppDomains[number]["domain"]; | ||
getPathname: (args: Parameters<(args: { | ||
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname */ | ||
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */ | ||
href: [AppPathnames] extends [never] ? string | { | ||
@@ -390,3 +390,3 @@ pathname: string; | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/navigation#getpathname | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
@@ -393,0 +393,0 @@ domain: AppDomains[number]["domain"]; |
import type { Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.tsx'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * We have to keep the cookie value in sync as Next.js might |
import type { ParsedUrlQueryInput } from 'node:querystring'; | ||
import type { UrlObject } from 'url'; | ||
import type { Locale } from 'use-intl'; | ||
import type { ResolvedRoutingConfig } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type StrictParams from './StrictParams.tsx'; | ||
import type { ResolvedRoutingConfig } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
import type StrictParams from './StrictParams.js'; | ||
type SearchParamValue = ParsedUrlQueryInput[keyof ParsedUrlQueryInput]; | ||
@@ -8,0 +8,0 @@ type HrefOrHrefWithParamsImpl<Pathname, Other> = Pathname extends `${string}[[...${string}` ? // Optional catch-all |
@@ -1,1 +0,1 @@ | ||
export { default } from './plugin/index.tsx'; | ||
export { default } from './plugin/index.js'; |
@@ -1,1 +0,1 @@ | ||
export default function createMessagesDeclaration(messagesPath: string): void; | ||
export default function createMessagesDeclaration(messagesPaths: Array<string>): void; |
import type { NextConfig } from 'next'; | ||
import type { PluginConfig } from './types.tsx'; | ||
import type { PluginConfig } from './types.js'; | ||
export default function createNextIntlPlugin(i18nPathOrConfig?: string | PluginConfig): (nextConfig?: NextConfig) => NextConfig; |
import type { NextConfig } from 'next'; | ||
import type { PluginConfig } from './types.tsx'; | ||
import type { PluginConfig } from './types.js'; | ||
export default function getNextConfig(pluginConfig: PluginConfig, nextConfig?: NextConfig): NextConfig & Partial<NextConfig>; |
@@ -1,1 +0,1 @@ | ||
export { default } from './createNextIntlPlugin.tsx'; | ||
export { default } from './createNextIntlPlugin.js'; |
export type PluginConfig = { | ||
requestConfig?: string; | ||
experimental?: { | ||
createMessagesDeclaration?: string; | ||
/** A path to the messages file that you'd like to create a declaration for. In case you want to consider multiple files, you can pass an array of paths. */ | ||
createMessagesDeclaration?: string | Array<string>; | ||
}; | ||
}; |
@@ -14,2 +14,2 @@ /** | ||
export declare const useFormatter: typeof base_useFormatter; | ||
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider.tsx'; | ||
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider.js'; |
@@ -8,9 +8,9 @@ /** | ||
*/ | ||
export { default as useLocale } from './useLocale.tsx'; | ||
export { default as useTranslations } from './useTranslations.tsx'; | ||
export { default as useFormatter } from './useFormatter.tsx'; | ||
export { default as useNow } from './useNow.tsx'; | ||
export { default as useTimeZone } from './useTimeZone.tsx'; | ||
export { default as useMessages } from './useMessages.tsx'; | ||
export { default as NextIntlClientProvider } from './NextIntlClientProviderServer.tsx'; | ||
export { default as useLocale } from './useLocale.js'; | ||
export { default as useTranslations } from './useTranslations.js'; | ||
export { default as useFormatter } from './useFormatter.js'; | ||
export { default as useNow } from './useNow.js'; | ||
export { default as useTimeZone } from './useTimeZone.js'; | ||
export { default as useMessages } from './useMessages.js'; | ||
export { default as NextIntlClientProvider } from './NextIntlClientProviderServer.js'; | ||
export * from 'use-intl/core'; |
import type { ComponentProps } from 'react'; | ||
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.tsx'; | ||
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.js'; | ||
type Props = ComponentProps<typeof BaseNextIntlClientProvider>; | ||
export default function NextIntlClientProviderServer({ formats, locale, now, timeZone, ...rest }: Props): Promise<import("react/jsx-runtime").JSX.Element>; | ||
export default function NextIntlClientProviderServer({ formats, locale, messages, now, timeZone, ...rest }: Props): Promise<import("react/jsx-runtime").JSX.Element>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import getConfig from '../server/react-server/getConfig.tsx'; | ||
import getConfig from '../server/react-server/getConfig.js'; | ||
export default function useConfig(hookName: string): Awaited<ReturnType<typeof getConfig>>; |
@@ -1,1 +0,1 @@ | ||
export * from './routing/index.tsx'; | ||
export * from './routing/index.js'; |
import type { NextResponse } from 'next/server.js'; | ||
import type { DomainsConfig, LocalePrefix, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from './types.tsx'; | ||
import type { DomainsConfig, LocalePrefix, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from './types.js'; | ||
type CookieAttributes = Pick<NonNullable<Parameters<typeof NextResponse.prototype.cookies.set>['2']>, 'maxAge' | 'domain' | 'partitioned' | 'path' | 'priority' | 'sameSite' | 'secure' | 'name'>; | ||
@@ -7,3 +7,3 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = { | ||
* All available locales. | ||
* @see https://next-intl-docs.vercel.app/docs/routing | ||
* @see https://next-intl.dev/docs/routing | ||
*/ | ||
@@ -13,3 +13,3 @@ locales: AppLocales; | ||
* Used when no locale matches. | ||
* @see https://next-intl-docs.vercel.app/docs/routing | ||
* @see https://next-intl.dev/docs/routing | ||
*/ | ||
@@ -19,3 +19,3 @@ defaultLocale: AppLocales[number]; | ||
* Configures whether and which prefix is shown for a given locale. | ||
* @see https://next-intl-docs.vercel.app/docs/routing#locale-prefix | ||
* @see https://next-intl.dev/docs/routing#locale-prefix | ||
**/ | ||
@@ -25,3 +25,3 @@ localePrefix?: LocalePrefix<AppLocales, AppLocalePrefixMode>; | ||
* Can be used to change the locale handling per domain. | ||
* @see https://next-intl-docs.vercel.app/docs/routing#domains | ||
* @see https://next-intl.dev/docs/routing#domains | ||
**/ | ||
@@ -31,3 +31,3 @@ domains?: AppDomains; | ||
* Can be used to disable the locale cookie or to customize it. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-cookie | ||
* @see https://next-intl.dev/docs/routing/middleware#locale-cookie | ||
*/ | ||
@@ -37,3 +37,3 @@ localeCookie?: boolean | CookieAttributes; | ||
* Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http | ||
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#alternate-links | ||
* @see https://next-intl.dev/docs/routing/middleware#alternate-links | ||
**/ | ||
@@ -43,3 +43,3 @@ alternateLinks?: boolean; | ||
* By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection. | ||
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-detection | ||
* @see https://next-intl.dev/docs/routing/middleware#locale-detection | ||
**/ | ||
@@ -50,3 +50,3 @@ localeDetection?: boolean; | ||
* A map of localized pathnames per locale. | ||
* @see https://next-intl-docs.vercel.app/docs/routing#pathnames | ||
* @see https://next-intl.dev/docs/routing#pathnames | ||
**/ | ||
@@ -80,3 +80,3 @@ pathnames: AppPathnames; | ||
export type InitializedLocaleCookieConfig = false | LocaleCookieConfig; | ||
export type LocaleCookieConfig = Omit<CookieAttributes, 'name' | 'maxAge' | 'sameSite'> & Required<Pick<CookieAttributes, 'name' | 'maxAge' | 'sameSite'>>; | ||
export type LocaleCookieConfig = Omit<CookieAttributes, 'name' | 'maxAge' | 'sameSite'> & Required<Pick<CookieAttributes, 'name' | 'sameSite'>>; | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
import type { RoutingConfig } from './config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from './types.tsx'; | ||
import type { RoutingConfig } from './config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from './types.js'; | ||
export default function defineRouting<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(config: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>; |
@@ -1,3 +0,3 @@ | ||
export type { Pathnames, LocalePrefix, DomainsConfig, LocalePrefixMode } from './types.tsx'; | ||
export { default as defineRouting } from './defineRouting.tsx'; | ||
export type { RoutingConfig } from './config.tsx'; | ||
export type { Pathnames, LocalePrefix, DomainsConfig, LocalePrefixMode } from './types.js'; | ||
export { default as defineRouting } from './defineRouting.js'; | ||
export type { RoutingConfig } from './config.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './server/react-client/index.tsx'; | ||
export * from './server/react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './server/react-server/index.tsx'; | ||
export * from './server/react-server/index.js'; |
@@ -1,2 +0,2 @@ | ||
import type { getFormatter as getFormatter_type, getLocale as getLocale_type, getMessages as getMessages_type, getNow as getNow_type, getRequestConfig as getRequestConfig_type, getTimeZone as getTimeZone_type, setRequestLocale as setRequestLocale_type } from '../react-server/index.tsx'; | ||
import type { getFormatter as getFormatter_type, getLocale as getLocale_type, getMessages as getMessages_type, getNow as getNow_type, getRequestConfig as getRequestConfig_type, getTimeZone as getTimeZone_type, setRequestLocale as setRequestLocale_type } from '../react-server/index.js'; | ||
export declare function getRequestConfig(...args: Parameters<typeof getRequestConfig_type>): ReturnType<typeof getRequestConfig_type>; | ||
@@ -3,0 +3,0 @@ export declare const getFormatter: typeof getFormatter_type; |
@@ -1,3 +0,3 @@ | ||
import type { GetRequestConfigParams, RequestConfig } from './getRequestConfig.tsx'; | ||
import type { GetRequestConfigParams, RequestConfig } from './getRequestConfig.js'; | ||
declare const _default: (params: GetRequestConfigParams) => RequestConfig | Promise<RequestConfig>; | ||
export default _default; |
import { type IntlConfig, type Locale, _createIntlFormatters } from 'use-intl/core'; | ||
declare function getConfigImpl(localeOverride?: Locale): Promise<IntlConfig & { | ||
declare function getConfigImpl(localeOverride?: Locale): Promise<{ | ||
locale: IntlConfig['locale']; | ||
formats?: NonNullable<IntlConfig['formats']>; | ||
timeZone: NonNullable<IntlConfig['timeZone']>; | ||
onError: NonNullable<IntlConfig['onError']>; | ||
getMessageFallback: NonNullable<IntlConfig['getMessageFallback']>; | ||
onError: NonNullable<IntlConfig['onError']>; | ||
timeZone: NonNullable<IntlConfig['timeZone']>; | ||
messages?: NonNullable<IntlConfig['messages']>; | ||
now?: NonNullable<IntlConfig['now']>; | ||
_formatters: ReturnType<typeof _createIntlFormatters>; | ||
@@ -7,0 +11,0 @@ }>; |
import type { Locale, useMessages as useMessagesType } from 'use-intl'; | ||
import getConfig from './getConfig.tsx'; | ||
import getConfig from './getConfig.js'; | ||
export declare function getMessagesFromConfig(config: Awaited<ReturnType<typeof getConfig>>): ReturnType<typeof useMessagesType>; | ||
@@ -4,0 +4,0 @@ export default function getMessages(opts?: { |
@@ -1,5 +0,5 @@ | ||
import type { IntlConfig } from 'use-intl/core'; | ||
import type { IntlConfig, Locale } from 'use-intl/core'; | ||
export type RequestConfig = Omit<IntlConfig, 'locale'> & { | ||
/** | ||
* @see https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request | ||
* @see https://next-intl.dev/docs/usage/configuration#i18n-request | ||
**/ | ||
@@ -10,2 +10,8 @@ locale: IntlConfig['locale']; | ||
/** | ||
* If you provide an explicit locale to an async server-side function like | ||
* `getTranslations({locale: 'en'})`, it will be passed via `locale` to | ||
* `getRequestConfig` so you can use it instead of the segment value. | ||
*/ | ||
locale?: Locale; | ||
/** | ||
* Typically corresponds to the `[locale]` segment that was matched by the middleware. | ||
@@ -23,3 +29,3 @@ * | ||
* | ||
* @see https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request | ||
* @see https://next-intl.dev/docs/usage/configuration#i18n-request | ||
*/ | ||
@@ -26,0 +32,0 @@ requestLocale: Promise<string | undefined>; |
import { createFormatter } from 'use-intl/core'; | ||
declare function getFormatterCachedImpl(config: Parameters<typeof createFormatter>[0]): { | ||
dateTime: (value: Date | number, formatOrOptions?: string | import("use-intl/core").DateTimeFormatOptions) => string; | ||
number: (value: number | bigint, formatOrOptions?: string | import("use-intl/core").NumberFormatOptions) => string; | ||
relativeTime: (date: number | Date, nowOrOptions?: import("use-intl/core").RelativeTimeFormatOptions["now"] | import("use-intl/core").RelativeTimeFormatOptions) => string; | ||
list: <Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, formatOrOptions?: string | Intl.ListFormatOptions) => Value extends string ? string : Iterable<import("react").ReactElement>; | ||
dateTimeRange: (start: Date | number, end: Date | number, formatOrOptions?: string | import("use-intl/core").DateTimeFormatOptions) => string; | ||
dateTime: { | ||
(value: Date | number, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
(value: Date | number, format?: string, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
}; | ||
number: { | ||
(value: number | bigint, options?: import("use-intl/core").NumberFormatOptions): string; | ||
(value: number | bigint, format?: string, options?: import("use-intl/core").NumberFormatOptions): string; | ||
}; | ||
relativeTime: { | ||
(date: number | Date, now?: import("use-intl/core").RelativeTimeFormatOptions["now"]): string; | ||
(date: number | Date, options?: import("use-intl/core").RelativeTimeFormatOptions): string; | ||
}; | ||
list: { | ||
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>; | ||
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, format?: string, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>; | ||
}; | ||
dateTimeRange: { | ||
(start: Date | number, end: Date | number, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
(start: Date | number, end: Date | number, format?: string, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
}; | ||
}; | ||
declare const getFormatterCached: typeof getFormatterCachedImpl; | ||
export default getFormatterCached; |
/** | ||
* Server-only APIs available via `next-intl/server`. | ||
*/ | ||
export { default as getRequestConfig, type GetRequestConfigParams, type RequestConfig } from './getRequestConfig.tsx'; | ||
export { default as getFormatter } from './getFormatter.tsx'; | ||
export { default as getNow } from './getNow.tsx'; | ||
export { default as getTimeZone } from './getTimeZone.tsx'; | ||
export { default as getTranslations } from './getTranslations.tsx'; | ||
export { default as getMessages } from './getMessages.tsx'; | ||
export { default as getLocale } from './getLocale.tsx'; | ||
export { setCachedRequestLocale as setRequestLocale } from './RequestLocaleCache.tsx'; | ||
export { default as getRequestConfig, type GetRequestConfigParams, type RequestConfig } from './getRequestConfig.js'; | ||
export { default as getFormatter } from './getFormatter.js'; | ||
export { default as getNow } from './getNow.js'; | ||
export { default as getTimeZone } from './getTimeZone.js'; | ||
export { default as getTranslations } from './getTranslations.js'; | ||
export { default as getMessages } from './getMessages.js'; | ||
export { default as getLocale } from './getLocale.js'; | ||
export { setCachedRequestLocale as setRequestLocale } from './RequestLocaleCache.js'; |
import type { LinkProps } from 'next/link.js'; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../routing/types.tsx'; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../routing/types.js'; | ||
type Href = LinkProps['href']; | ||
@@ -15,4 +15,6 @@ export declare function isLocalizableHref(href: Href): boolean; | ||
export declare function getLocalePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): string; | ||
export declare function getLocaleAsPrefix(locale: string): string; | ||
export declare function templateToRegex(template: string): RegExp; | ||
export declare function getSortedPathnames(pathnames: Array<string>): string[]; | ||
export declare function isPromise<Value>(value: Value | Promise<Value>): value is Promise<Value>; | ||
export {}; |
{ | ||
"name": "next-intl", | ||
"version": "4.0.0-beta-18156c4", | ||
"version": "4.0.0-beta-22cf1cd", | ||
"sideEffects": false, | ||
@@ -14,3 +14,3 @@ "author": "Jan Amann <jan@amann.work>", | ||
"license": "MIT", | ||
"homepage": "https://next-intl-docs.vercel.app", | ||
"homepage": "https://next-intl.dev", | ||
"repository": { | ||
@@ -116,7 +116,7 @@ "type": "git", | ||
"negotiator": "^1.0.0", | ||
"use-intl": "4.0.0-beta-18156c4" | ||
"use-intl": "4.0.0-beta-22cf1cd" | ||
}, | ||
"peerDependencies": { | ||
"next": "^13.0.0 || ^14.0.0 || ^15.0.0", | ||
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0", | ||
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0", | ||
"typescript": "^5.0.0" | ||
@@ -129,3 +129,3 @@ }, | ||
}, | ||
"gitHead": "c2e8c72ec78937a28955625dc1ed9dc2a10c4d32" | ||
"gitHead": "4c488a143d58b57453b167b59b8061e3263016dc" | ||
} |
<h1 align="center"> | ||
<br> | ||
<a href="https://next-intl-docs.vercel.app/"> | ||
<a href="https://next-intl.dev"> | ||
<picture> | ||
@@ -32,6 +32,6 @@ <source media="(prefers-color-scheme: dark)" srcset="media/logo-dark-mode.svg"> | ||
import {useTranslations} from 'next-intl'; | ||
export default function UserProfile({user}) { | ||
const t = useTranslations('UserProfile'); | ||
return ( | ||
@@ -62,6 +62,6 @@ <section> | ||
### [→ Read the docs](https://next-intl-docs.vercel.app/) | ||
### [→ Read the docs](https://next-intl.dev) | ||
<div align="center"> | ||
<a href="https://next-intl-docs.vercel.app/redirect?href=https://crowdin.com" target="_blank"> | ||
<a href="https://next-intl.dev/redirect?href=https://crowdin.com" target="_blank"> | ||
<img width="350" src="media/partner.svg" alt="Crowdin logo"> | ||
@@ -68,0 +68,0 @@ </a> |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
244472
1.43%205
1.49%4016
2.19%19
35.71%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated