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

44 lines 1.34 kB
export type SetLocaleFn = (newLocale: Locale, options?: { reload?: boolean; }) => void | Promise<void>; /** * @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise<void>} SetLocaleFn */ /** * Set the locale. * * Updates the locale using your configured strategies (cookie, localStorage, URL, etc.). * By default, this reloads the page on the client to reflect the new locale. Reloading * can be disabled by passing `reload: false` as an option, but you'll need to ensure * the UI updates to reflect the new locale. * * If any custom strategy's `setLocale` function is async, then this function * will become async as well. * * @see https://paraglidejs.com/strategy * * @example * setLocale('en'); * * @example * setLocale('en', { reload: false }); * * @type {SetLocaleFn} */ export declare let setLocale: SetLocaleFn; /** * Overwrite the `setLocale()` function. * * Use this function to overwrite how the locale is set. For example, * modify a cookie, env variable, or a user's preference. * * @example * overwriteSetLocale((newLocale) => { * // set the locale in a cookie * return Cookies.set('locale', newLocale) * }); * * @param {SetLocaleFn} fn */ export declare const overwriteSetLocale: (fn: SetLocaleFn) => void; //# sourceMappingURL=set-locale.d.ts.map