refine icon indicating copy to clipboard operation
refine copied to clipboard

[FEAT] add `useTranslation` hook

Open alicanerdurmaz opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

Refine has three hooks to access i18nProvider methods

The following methods can be combined into one hook for a better developer experience.

  • https://refine.dev/docs/i18n/hooks/use-get-locale/
  • https://refine.dev/docs/i18n/hooks/use-set-locale/
  • https://refine.dev/docs/i18n/hooks/use-translate/

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

Example of improvements:

import {
-  useGetLocale,
-  useSetLocale,
-  useTranslate,
+  useTranslation,
} from "@refinedev/core";

export const MyComponent = () => {
-  const setLocale = useSetLocale();
-  const locale = useGetLocale();
-  const translate = useTranslate();

+  const { translate, getLocale, changeLocale } = useTranslation();

  return <div>{/* ... */}</div>;
};

alicanerdurmaz avatar Mar 08 '24 12:03 alicanerdurmaz