Skip to main content
Version: 2.xx.xx


If you need to know the current locale, refine provides the useGetLocale hook. It returns the getLocale method from i18nProvider under the hood.


You can get the locale value from the i18nProvider that you provided.
For example, <LanguageSwitcher> component needs to know the current locale in order to disable the button for the current language.

import { Button, useTranslate, useGetLocale, useSetLocale } from "@pankod/refine";

export const LanguageSwitcher = () => {
const changeLanguage = useSetLocale();

const locale = useGetLocale();
const currentLocale = locale();

return (
disabled={currentLocale === "en"}
onClick={() => changeLanguage("en")}
disabled={currentLocale === "es"}
onClick={() => changeLanguage("es")}

This hook can only be used if i18nProvider is provided.