diff --git a/packages/client/src/hooks/useLocalize.ts b/packages/client/src/hooks/useLocalize.ts index 83366cff16..cab3dd6547 100644 --- a/packages/client/src/hooks/useLocalize.ts +++ b/packages/client/src/hooks/useLocalize.ts @@ -1,21 +1,16 @@ -import { useEffect } from 'react'; +import { useCallback } from 'react'; import { TOptions } from 'i18next'; -import { useAtomValue } from 'jotai'; import { useTranslation } from 'react-i18next'; import { resources } from '~/locales/i18n'; -import { langAtom } from '~/store'; export type TranslationKeys = keyof typeof resources.en.translation; +/** Language lifecycle is managed by the host app — do not add i18n.changeLanguage() calls here. */ export default function useLocalize() { - const lang = useAtomValue(langAtom); - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); - useEffect(() => { - if (i18n.language !== lang) { - i18n.changeLanguage(lang); - } - }, [lang, i18n]); - - return (phraseKey: TranslationKeys, options?: TOptions) => t(phraseKey, options); + return useCallback( + (phraseKey: TranslationKeys, options?: TOptions) => t(phraseKey, options), + [t], + ); } diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 6e23be6e04..36a3f05844 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -1,7 +1,6 @@ import { atom } from 'jotai'; import { NotificationSeverity } from '~/common'; -export const langAtom = atom('en'); export const chatDirectionAtom = atom('ltr'); export const fontSizeAtom = atom('text-base');