Files
calendar/packages/lib/hooks/useLocale.ts
T
Keith WilliamsandGitHub 381f2781a3 perf: remove atoms monorepo imports (#19688)
* perf: Remove atoms/monorepo barrel exports

* Removed more exports

* completely removed the monorepo file

* fixed types

* fixing tests

* fixing package errors

* Pushing latest

* Fixed atoms build

* hack to fix type

* Fixed web build
2025-03-05 09:49:13 -03:00

23 lines
664 B
TypeScript

import { useTranslation } from "next-i18next";
import { useAtomsContext } from "@calcom/atoms/hooks/useAtomsContext";
export const useLocale = (namespace: Parameters<typeof useTranslation>[0] = "common") => {
const context = useAtomsContext();
const { i18n, t } = useTranslation(namespace);
const isLocaleReady = Object.keys(i18n).length > 0;
if (context?.clientId) {
return { i18n: context.i18n, t: context.t, isLocaleReady: true } as unknown as {
i18n: ReturnType<typeof useTranslation>["i18n"];
t: ReturnType<typeof useTranslation>["t"];
isLocaleReady: boolean;
};
}
return {
i18n,
t,
isLocaleReady,
};
};