UNPKG

@inlang/paraglide-js

Version:

[![NPM Downloads](https://img.shields.io/npm/dw/%40inlang%2Fparaglide-js?logo=npm&logoColor=red&label=npm%20downloads)](https://www.npmjs.com/package/@inlang/paraglide-js) [![GitHub Issues](https://img.shields.io/github/issues-closed/opral/paraglide-js?lo

42 lines 1.63 kB
import { strategy } from "./variables.js"; export type ExtractLocaleFromRequestOptions = { /** * - Effective request URL to use for route matching and locale detection with the URL strategy. */ effectiveRequestUrl?: string | URL; }; /** * @typedef {object} ExtractLocaleFromRequestOptions * @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching and locale detection with the URL strategy. */ /** * Extracts a locale from a request. * * Use the function on the server to extract the locale * from a request. * * The function goes through the strategies in the order * they are defined. If a strategy returns an invalid locale, * it will fall back to the next strategy. * * Note: Custom server strategies are not supported in this synchronous version. * Use `extractLocaleFromRequestAsync` if you need custom server strategies with async getLocale methods. * * @example * const locale = extractLocaleFromRequest(request); * * @param {Request} request * @param {ExtractLocaleFromRequestOptions} [options] * @returns {Locale} */ export declare const extractLocaleFromRequest: (request: Request, options?: ExtractLocaleFromRequestOptions) => Locale; /** * Extracts a locale from a request using the provided strategy order. * * @param {Request} request * @param {typeof strategy} strategies * @param {string | URL} [url] * @returns {Locale} */ export declare const extractLocaleFromRequestWithStrategies: (request: Request, strategies: typeof strategy, url?: string | URL) => Locale; //# sourceMappingURL=extract-locale-from-request.d.ts.map