UNPKG

@refinedev/core

Version:

Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.

16 lines (12 loc) 547 B
import { useCallback, useContext } from "react"; import { I18nContext } from "@contexts/i18n"; /** * If you need to change the locale at runtime, refine provides the `useSetLocale` hook. * It returns the changeLocale method from `i18nProvider` under the hood. * * @see {@link https://refine.dev/docs/api-reference/core/hooks/translate/useSetLocale} for more details. */ export const useSetLocale = () => { const { i18nProvider } = useContext(I18nContext); return useCallback((lang: string) => i18nProvider?.changeLocale(lang), []); };