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

43 lines 1.37 kB
/** * Get the current locale. * * The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.) * in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage * which is set by the `paraglideMiddleware()`. * * @see https://paraglidejs.com/strategy - Configure locale detection strategies * * @example * if (getLocale() === 'de') { * console.log('Germany 🇩🇪'); * } else if (getLocale() === 'nl') { * console.log('Netherlands 🇳🇱'); * } * * @returns {Locale} The current locale. */ export declare let getLocale: () => Locale; /** * Resolve locale for a given URL using route-aware strategies. * * @param {string | URL} url * @returns {Locale} */ export declare function getLocaleForUrl(url: string | URL): Locale; /** * Overwrite the `getLocale()` function. * * Use this function to overwrite how the locale is resolved. This is useful * for custom locale resolution or advanced use cases like SSG with concurrent rendering. * * @see https://paraglidejs.com/strategy * * @example * overwriteGetLocale(() => { * return Cookies.get('locale') ?? baseLocale * }); * * @param {() => Locale} fn - The new implementation for `getLocale()`. */ export declare const overwriteGetLocale: (fn: () => Locale) => void; //# sourceMappingURL=get-locale.d.ts.map