Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🗣️ fix: Prevent `@librechat/client` useLocalize from Overwriting Host App Language State (#12515)

Shahryar Tayeb2140729a54ed
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<string>('en');
export const chatDirectionAtom = atom<string>('ltr');
export const fontSizeAtom = atom<string>('text-base');