Reasonable way to avoid locale resetting on preload? #145
Unanswered
henrikvilhelmberglund
asked this question in
Q&A
Replies: 2 comments 4 replies
-
|
Hi @henrikvilhelmberglund! |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
I am encountering exactly the same issue. I am using the
@henrikvilhelmberglund just curious as to what solution you ended up using. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a few buttons for selecting the user language which change the $locale store to the locale string. I had an issue where $locale would get reset to whatever initLocale was in the +layout.js when hovering over links (preload) and when changing the route.
I fixed(?) it by using the following code:
which seems to work as it uses the $locale store value if it exists, otherwise "en" as a default. (Should probably use cookies/localstorage for this later)
My main question is, is there a better way to do this? I'm very new to i18n.
Beta Was this translation helpful? Give feedback.
All reactions