🗣️ fix: Prevent @librechat/client useLocalize from Overwriting Host App Language State#12515
Merged
danny-avila merged 3 commits intoApr 3, 2026
Conversation
useLocalize hook in main client/ and packages/client@librechat/client useLocalize from Overwriting Host App Language State
danny-avila
force-pushed
the
fix/languge-flicker-inconsistent-lang-init
branch
from
April 3, 2026 18:58
a077c3d to
873c6f7
Compare
yidianyiko
pushed a commit
to yidianyiko/LibreChat
that referenced
this pull request
Apr 13, 2026
… App Language State (danny-avila#12515) * 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 <danny@librechat.ai>
jcbartle
pushed a commit
to jcbartle/LibreChat
that referenced
this pull request
May 11, 2026
… App Language State (danny-avila#12515) * 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 <danny@librechat.ai>
ThomasVuNguyen
pushed a commit
to ThomasVuNguyen/LibreChat
that referenced
this pull request
Jul 15, 2026
… App Language State (danny-avila#12515) * 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 <danny@librechat.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
langAtomis hardcoded toeninpackages/client/src/store.tsin comparison with the main app's
client/src/hooks/useLocalize.tswhich reads from real sources inclient/src/store/language.tsBoth hooks call
i18n.changeLanguage()on the same i18next singleton. When the packages/client hook fires first with'en', it overwrites the language before the main app hook can correct it.(look at value of i18nextLng in localstorage)
Screen.Recording.2026-04-02.at.0.16.31.PM.mov
Change Type
How the bug plays out
/d/newwith language set to e.g.,fr@librechat/client(e.g.,Button,Input,Select)useLocalizefrompackages/client/src/hooks/useLocalize.tslangAtom→'en'(hardcoded default)i18n.language(detected asfr) !=='en', it callsi18n.changeLanguage('en')i18nextLng = 'en'to localStorage. the user sees the flicker to English(not very visible in the dialog case but can be worse when you are fetching data and have to wait for the result)useLocalize(fromclient/src/hooks/useLocalize.ts) reads the Recoil atom (fr) and callsi18n.changeLanguage('fr')fixing it back since no data is fetched it happens fast.i18nextLngis alreadyfrfrom step 7, soi18n.languagematcheslangAtom... wait, no,langAtomis still'en'Checklist
Proposed fix
It removes the language overwrite from
packages/client/src/hooks/useLocalize.tshook and only read it.Alt fix: initialize
langAtomfrom actual language sources.