/** * Lower-level URL localization function, primarily used in server contexts. * * This function is designed for server-side usage where you need precise control * over URL localization, such as in middleware or request handlers. It works with * URL objects and always returns absolute URLs. * * For client-side UI components, use `localizeHref()` instead, which provides * a more convenient API with relative paths and automatic locale detection. * * @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/i18n-routing * * @example * ```typescript * // Server middleware example * app.use((req, res, next) => { * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`); * const localized = localizeUrl(url, { locale: "de" }); * * if (localized.href !== url.href) { * return res.redirect(localized.href); * } * next(); * }); * ``` * * @example * ```typescript * // Using with URL patterns * const url = new URL("https://example.com/about"); * localizeUrl(url, { locale: "de" }); * // => URL("https://example.com/de/about") * * // Using with domain-based localization * const url = new URL("https://example.com/store"); * localizeUrl(url, { locale: "de" }); * // => URL("https://de.example.com/store") * ``` * * @param {string | URL} url - The URL to localize. If string, must be absolute. * @param {object} [options] - Options for localization * @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale() * @returns {URL} The localized URL, always absolute */ export function localizeUrl(url: string | URL, options?: { locale?: string | undefined; }): URL; /** * Low-level URL de-localization function, primarily used in server contexts. * * This function is designed for server-side usage where you need precise control * over URL de-localization, such as in middleware or request handlers. It works with * URL objects and always returns absolute URLs. * * For client-side UI components, use `deLocalizeHref()` instead, which provides * a more convenient API with relative paths. * * @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/i18n-routing * * @example * ```typescript * // Server middleware example * app.use((req, res, next) => { * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`); * const baseUrl = deLocalizeUrl(url); * * // Store the base URL for later use * req.baseUrl = baseUrl; * next(); * }); * ``` * * @example * ```typescript * // Using with URL patterns * const url = new URL("https://example.com/de/about"); * deLocalizeUrl(url); // => URL("https://example.com/about") * * // Using with domain-based localization * const url = new URL("https://de.example.com/store"); * deLocalizeUrl(url); // => URL("https://example.com/store") * ``` * * @param {string | URL} url - The URL to de-localize. If string, must be absolute. * @returns {URL} The de-localized URL, always absolute */ export function deLocalizeUrl(url: string | URL): URL; /** * Aggregates named groups from various parts of the URLPattern match result. * * * @param {any} match - The URLPattern match result object. * @returns {Record} An object containing all named groups from the match. */ export function aggregateGroups(match: any): Record; //# sourceMappingURL=localize-url.d.ts.map