-
-
Notifications
You must be signed in to change notification settings - Fork 58
Reactive Current Locale #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactive Current Locale #200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just looked to see if there is a way to reactively retrieve the current language and have now discovered this PR.
Looks good.
Would be great if this could be merged asap :)
@xiCO2k, are there any plans to merge this PR soon? |
Thanks for that. |
I believe this broke something. Prior to this I was using loadLanguageAsync() to switch locales and getActiveLanguage() would detect the change, Now it always returns the original html lang. The languages do switch, loadLanguageAsync() works, but after switching locales getActiveLanguage() doesn't detect the change. I'm going to need to freeze this at the previous version. |
Hi @tcytra, Could you provide a sample to reproduce the issue? This change shouldn’t affect anything else—it simply sets Maybe you forgot the |
Thanks for the response. I revisited this morning and (without changing anything) it's working for me again. I don't know why it stopped working or why it started working again. My apologies for a false alarm. |
export const currentLocale: ComputedRef<string> = computed(() => { | ||
return I18n.getSharedInstance().getCurrentLanguage().value | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this change in the release (thx!). But this part here is incorrect.
Whenever the locale change, you call getCurrentLanguage()
(because its in the computed). and that method creates a new computed, returns it and you grab the value from it. By definition, computeds should never be recreated inside another computed.
So the correct approach here would be to simply use the computed directly:
export const currentLocale = I18n.getSharedInstance().getCurrentLanguage()
(You also wouldnt write computed(() => computed(() => something).value)
)
Add reactive current locale - Related to this #192