Server Side Rendering, attribute locale is ignored
See original GitHub issueI am having an issue, locale: 'fr'
attribute is ignored when I am rendering my React app on Server Side.
When the client has finished to download the js bundles, my locale is not ignored anymore then it’s OK. But it does a FOUC (Flash Of Unstyled Component).
I would better say it does a FOMLD (Flash Of Misconfigured Locale Date). I mean 2 seconds in English then French (because my browser is in french)
- When I am running on my local environment (my Macintosh) it works fine !!! I get the browser language with express js req.headers[‘Accept-Language’] and then it goes in a date time for example
DateTime.fromFormat(myGrossDateTime, 'yyyy-MM-dd', {
zone: 'UTC',
locale: 'fr'
})
.setZone(timezone)
.toLocaleString({
year: '2-digit',
month: '2-digit',
day: '2-digit'
})
- When I am running in my production environment on my Kubernetes Cluster. I do exactly the same ! req.headers[‘Accept-Language’] is working fine I already checked. But
DateTime.fromObject({ locale: "fr" }).resolvedLocaleOpts();
falls back onen-us
I checked your code https://github.com/moment/luxon/blob/master/src/impl/locale.js#L238
resolvedOptions() {
if (this.hasIntl) {
return this.dtf.resolvedOptions();
} else {
return {
locale: "en-US",
numberingSystem: "latn",
outputCalendar: "gregory"
};
}
}
And yes my Node.js version has Intl support (docker alpine:3.11). I checked myself using the exact code you use, try catch…
It keeps pointing on
{
locale: "en-US",
numberingSystem: "latn",
outputCalendar: "gregory"
}
Why it keeps doing this on my production environment please ? any clue ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
react sever-side rendering dealing with `window`, `localStorage`
Server -side rendering means your application is universal (as know as isomorphic). ... require JSDOM to use DOM API on server side. Ignoring...
Read more >beta.15 to beta.20 · Discussion #7495 · facebook/docusaurus
[ERROR] Docusaurus server-side rendering could not render static page with path "/noticias/tags/covid-19". TypeError: Cannot destructure ...
Read more >Localized Server-Side Rendering with React | Phrase
One thing we can do with the intl object is ask it for the active locale via the intl.locale attribute. Since we set...
Read more >Advanced Features: Internationalized Routing - Next.js
When localeDetection is set to false Next.js will no longer automatically redirect based on the user's preferred locale and will only provide locale...
Read more >Server-Side Rendering (SSR) - Vue.js
In such cases, the local time conversion should also be performed as a client-only operation. When Vue encounters a hydration mismatch, it will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You are right !
My Macintosh
test icambron septembre
in frenchMy Kubernetes cluster
test icambron September
in englishThis is my fucking docker import of Node.js
alpine:3.11
Alpine is a compressed Node.js version made by Linux, and it messes this up, I am not counting the MegaBytes on my server whatever.
Many thanks, and by the way, great module !! great support !! Au revoir, voila.
Just add ICU support for Node.js https://moment.github.io/luxon/docs/manual/install.html and it works just fine
3 ligns in your Dockerfile
The full Dockerfile below