Skip to content
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

fix(lazy): make client use translations loaded on the server #823

Merged
merged 7 commits into from
Aug 3, 2020

Conversation

rchl
Copy link
Collaborator

@rchl rchl commented Aug 3, 2020

Instead of client importing and processing messages (translations)
itself on load, pass already loaded messages from the server through
"nuxtState". This will in most cases allow avoiding triggering an extra
network request to fetch lang file for the given locale.

Slight behavior change: The client will no longer import the lang file
itself for the initially used locale. That means that if the lang file
has exported a function, it will only be called on the server and not on
the client. This matches behavior of "asyncData" and I think it makes
more sense in general.

Resolves #486
Resolves #663

Instead of client importing and processing messages (translations)
itself on load pass already loaded messages from the server through
nuxtState. This will in most cases allow avoiding triggering an extra
network request to fetch lang file for given locale.

Slight behavior change: The client will no longer import the lang file
itself for the initially used locale. That means that if the lang file
has exported a function, it will only be called on the server and not
the client. This matches behavior of "asyncData" and I think it makes
more sense in general.

Resolves #486
Resolves #663
@rchl rchl merged commit 06bc5f1 into master Aug 3, 2020
@rchl rchl deleted the fix/locale-server-state branch August 3, 2020 20:01
@divine
Copy link

divine commented Aug 3, 2020

New release as well?

@rchl
Copy link
Collaborator Author

rchl commented Aug 4, 2020

Published in v6.13.3

@tvld
Copy link

tvld commented Aug 4, 2020

Great ))....
Q: is this a breaking change for clients that load the language module proactively at present ?

@rchl
Copy link
Collaborator Author

rchl commented Aug 4, 2020

What exact configuration do you have in mind?
(This will only affect users that use lazy: true)

@tvld
Copy link

tvld commented Aug 4, 2020

We use lazy=true but, and I just checked, it seems not in the projects were we load the files ourselves so to work around the issue... So my question was premature; sorry)).
We will rewrite one of the projects with v6.13.3 and will come back if any questions remain on that front )))
Thanks again ))

@yakovyarmo
Copy link

for me it still doesn't work since process.server is undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants