From 2140729a54eda0304be59f3f4f51e7ca298fea8b Mon Sep 17 00:00:00 2001 From: Shahryar Tayeb <48182832+shtayeb@users.noreply.github.com> Date: Sat, 4 Apr 2026 04:01:39 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=A3=EF=B8=8F=20fix:=20Prevent=20`@libr?= =?UTF-8?q?echat/client`=20useLocalize=20from=20Overwriting=20Host=20App?= =?UTF-8?q?=20Language=20State=20(#12515)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * directly returns the translation function without managing language state in client package * chore: remove unused langAtom from packages/client store * fix: add useCallback to match canonical useLocalize, add guard comment --------- Co-authored-by: Danny Avila --- packages/client/src/hooks/useLocalize.ts | 19 +++++++------------ packages/client/src/store.ts | 1 - 2 files changed, 7 insertions(+), 13 deletions(-) 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');