Closed YehorPytomets closed 2 years ago
Thanks for the bug report!
This was indeed missing in the 2.0.0-beta.0 release. The code - as you saw - was already there on main. I just cut a 2.0.0-beta.1 release to include the i18next object's reactivity.
All computed properties from you example should now update when the language is changed.
Happy to hear back if this solves the problem for you.
@kkuegler, thank you for your response!
Indeed, the new version worked for us and the i18next
object is now reactive. Thank you for your solution.
P.S. I suppose the issue can now be closed.
Glad to hear, it works for you :)
🐛 Bug Report
Hello!
When using
i18next
object returned from theuseTranslation()
in computed properties to get the current language, for example in a language switcher component, we expect it to be reactive as docs in the index.ts specify. But it it isn't.To Reproduce
For example, in the following component, neither of the computed properties will be updated after the language change:
But the
t()
function updates as expected. To temporary work around this issue we've created our local composable that makes thei18next
reactive by subscribing to common i18next events:Could you please fix that and make the
i18next
returned fromuseTranslation()
reactive, or clarify why it is not reactive if it is so by design and describe this in the documentation explicitly. Because the composable name makes us believe that the returned values are reactive, if not stated the opposite. Hope our solution helps in some way.I would be grateful to get any feedback on that.
Expected behavior
It is expected that the
i18next
is reactive and can be used in computed properties to get the current language.Your Environment