-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Description
Which @angular/* package(s) are the source of the bug?
localize
Is this a regression?
Yes
Description
I have an SSR app that uses loadTranslations
to avoid building dist files for each locale. More specifically, I bootstrap the language based on the request's cookies or headers.
This works well with strings marked with $localize
, they're always in the correct language ✨ However, for strings marked with i18n
attributes, the server seems to generate the response once, and then use it for every response thereafter 😢
So if I run the server, then request the app in French, I will get the first response in French, and then the app bootstraps in the browser, and everything is still in French, great! 🚀
But! When I then switch to English, the first response will still be in French for strings marked with i18n
! Then the app bootstraps, and everything is in English correctly. 🤔
You can check this by pulling and running the reproduction repo I created, following the steps I described above and looking at the first response you get from the server. This happens every time you restart the server, it seems to cache the first response it serves (at least for strings marked with i18n
).
I've been trying to look in the source code but I don't understand this! Do you know how I can fix it? What's the difference between marking a string with i18n
vs $localize
?
Please provide a link to a minimal reproduction of the bug
https://github.com/aleesaan/angular-i18n-ssr
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 16.2.1
Node: 16.20.1
P
67E9
ackage Manager: npm 8.19.4
OS: darwin arm64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1602.1 (cli-only)
@angular-devkit/core 16.2.1 (cli-only)
@angular-devkit/schematics 16.2.1 (cli-only)
@schematics/angular 16.2.1 (cli-only)
Anything else?
No response