UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

43 lines (42 loc) 1.31 kB
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation"; //#region src/client/useLocale.d.ts type UseLocaleProps = { isCookieEnabled?: boolean; onLocaleChange?: (locale: DeclaredLocales) => void; }; type UseLocaleResult = { locale: DeclaredLocales; defaultLocale: DeclaredLocales; availableLocales: DeclaredLocales[]; setLocale: (locale: LocalesValues) => void; }; /** * Client-side hook to get the current locale and related locale management functions. * * @param props - Optional properties for the hook. * @returns An object containing the current locale, default locale, available locales, and a function to update the locale. * * @example * ```tsx * import { useLocale } from 'react-intlayer'; * * const LocaleSwitcher = () => { * const { locale, setLocale, availableLocales } = useLocale(); * * return ( * <select value={locale} onChange={(e) => setLocale(e.target.value)}> * {availableLocales.map((loc) => ( * <option key={loc} value={loc}>{loc}</option> * ))} * </select> * ); * }; * ``` */ declare const useLocale: ({ isCookieEnabled, onLocaleChange }?: UseLocaleProps) => UseLocaleResult; //#endregion export { UseLocaleProps, UseLocaleResult, useLocale }; //# sourceMappingURL=useLocale.d.ts.map