import React from 'react'; import { NavigateFunction, Location } from 'react-router'; /** * The context for locale information derived from the URL path. */ declare const RouteLocaleContext: React.Context; /** * Represents the locale information derived from the URL path. */ type RouteLocale = { /** * The resolved locale code (falls back to defaultLocale). */ locale: string; /** * An optional string indicating the locale explicitly requested. */ requestLocale?: string; /** * The pathname of the current request, can be used to build locale-specific urls. */ requestPathname: string; /** * Navigate to a new locale, preserving the request pathname, search, and hash parameters. * * @param locale The locale code to change to, or empty to remove the locale prefix. */ changeLocale: (locale: string | undefined) => Promise | void; }; /** * React hook that derives the active locale from the current URL path. * * @returns A `RouteLocale` object containing locale information. */ declare function useRouteLocale(): RouteLocale; /** * Finds and resolves the locale from a URL path segment. * * @param localeParam The locale segment extracted from the URL path. Should not be normalized. * @returns An object containing: * - `locale` - The resolved locale code if found, otherwise undefined * - `excluded` - Boolean indicating if the path matches an excluded prefix */ declare function findLocale(localeParam: string | undefined): { /** The resolved locale code if found, otherwise undefined. */ locale?: string; /** Boolean indicating if the path matches an excluded prefix. */ excluded: boolean; }; /** * Parses the pathname to remove the locale prefix. * * @param pathname The full URL pathname (e.g., "/en/products") * @param localeParam The locale segment extracted from the URL path (e.g., "en") * @returns The pathname without the locale prefix (e.g., "/products") */ declare function stripPathnameLocalePrefix(pathname: string, localeParam: string | undefined): string; /** * Creates a RouteLocale context object. * * This is an internal function used by I18nApp. * * @param navigate The navigate function for changing the locale. See `useNavigate()`. * @param localeParam The locale segment extracted from the URL path. See `useParams()`. * @param locale The resolved locale code. * @param location The current location object. */ declare function createLocalePathContext(navigate: NavigateFunction, localeParam: string | undefined, locale: string, location: Location): RouteLocale; export { RouteLocaleContext as a, createLocalePathContext as c, findLocale as f, stripPathnameLocalePrefix as s, useRouteLocale as u }; export type { RouteLocale as R };