Files
calendar/packages/lib/hooks/useLocale.ts
T
Lauris SkraucisandGitHub 74e5f4bf37 feat: atoms as npm package (#14160)
* fix: getEnv not returning fallback API_URL breaking examples app

* refactor: use vite as the only way to build atoms

* refactor: web use atoms from web.ts and rest from dist

* refactor: update atoms version, description and set privacy to public

* fix: lib and ui import from web atoms

* refactor: rename @calcom/platform-atoms to @calcom/atoms

* feat: atoms as npm works with example app outside monorepo

* start atoms from v1.0.0

* refactor: monorepo atoms for internal use

* document atoms publishing

* refactor: remove unused import in v2

* fix: mistakes made during main merge

* refactor: move back examples app while still having it in atoms-examples repo

* refactor: monorepo examples readme

* feat: atoms yarn publish command

* refactor: atoms css file simplify

* fix: mocking atoms in ui unit test

* fix: mocking atoms in app-store unit test
2024-03-21 14:33:10 -03:00

23 lines
651 B
TypeScript

import { useTranslation } from "next-i18next";
import { useAtomsContext } from "@calcom/atoms/monorepo";
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,
};
};