Closed Burtonium closed 2 years ago
Hi @Burtonium Sorry for the delay, but I couldn't reproduce
thanks for the solution, it worked for me too, personally I see the code very suitable
This also worked for me, and I find the solution very elegant! Thank you very much
This should fix using latest version of Nuxt.
Thanks for your fix
When using both nuxt-i18n and nuxtjs/moment I ran into an interesting issue that I think deserves the attention of this module. If this is the wrong place for this issue then I apologize.
Essentially, I wanted to globally set the locale as the following plugin:
@/plugins/moment.js
When working in universal mode, this works as expected. But, when working in generated mode the dates would flicker with the last locale of the last generated route because moment does not get reinitialized between routes.
Here's an example: https://github.com/Burtonium/moment-test/tree/bug-example https://moment-i18n-bug-example.netlify.com/
You'll see the date flicker in Spanish. If not, throttle your internet in the browser to replicate.
The fix was to only locally use the locale and overriding the moment instance completely and use local instances of moment:
@/plugins/moment.js
This fixed everything for me. Not sure if this is the right way to go about it but would like to know your thoughts. Maybe a warning in the documentation with a proposed solution would go a long way and save people some time. Let me know.