Skip to main content
Version: 4.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.


This hook can only be used if i18nProvider is provided.

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 { useTranslate, useGetLocale, useSetLocale } from "@refinedev/core";

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

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

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