Dealing with i18n of dates

I’m French, and started using Netlify to build and host a site in French, but I feel like Netlify currently lacks support for i18n for us not English speaking/writing users.

I’m using Eleventy to build the static site, and Luxon to format dates, but Netlify currently doesn’t have full-icu, so I use a dirty hack to convert date to French:

eleventyConfig.addFilter("displayDate", function(date) {
    return DateTime.fromJSDate(date, { zone: "Europe/Paris" })
      .replace(/([0-9]{4}) (M[0-9]{2}) ([0-9]{2})/, "$3 $2 $1")
      .replace(/M01/, "janvier")
      .replace(/M02/, "février")
      .replace(/M03/, "mars")
      .replace(/M04/, "avril")
      .replace(/M05/, "mai")
      .replace(/M06/, "juin")
      .replace(/M07/, "juillet")
      .replace(/M08/, "août")
      .replace(/M09/, "septembre")
      .replace(/M10/, "octobre")
      .replace(/M11/, "novembre")
      .replace(/M12/, "décembre");

The repository is here:

Is there any better way to manage dates i18n when full-icu is not available?

How could I convince Netlify that adding full-icu would be a good idea? :grin:


Why can’t you use full-icu? I think it’s just an npm module that you’d install in your package.json or yarn.lock (well, please add with the utility not by manual editing :)) , though I am not certain and maybe there is more to it than I can see that you could tell me about?

From the issue I linked to, it looks like it’s not possible:

Ah, great eye! I don’t know the answer to the questions asked in that thread and I doubt we’ll make any preemptive changes around it, so if you’d like to figure it out and submit a PR to provide official support, it would be the fastest way for us to consider changing the situation there.

I’m not sure this is even possible with our current layout of fetching node using NVM, but maybe you know :slight_smile:

I don’t know at all, that’s why I asked! :sweat_smile:

I hope someone who needs to publish content in any other language than English will know what to do and make a PR… :disappointed_relieved:

I think many people publish content in many languages. Your mentioned software is only one way to do it, of course, many others “just work”. While this doesn’t help in generating your content, we can serve content based on browser language, using our Language Redirects:

I know this feature indeed, but it doesn’t help me at all on this dates i18n topic, for a site that is only French.

Hmm, what I was trying to imply is that there are other ways to use even i18n data than the specific package you are referring to. If you don’t want to PR the necessary additions to our build image (and of course I do not blame you; that isn’t your job :)) you might try googling or asking on stack overflow for other ways of solving your issue using packages that are entirely contained as npm packages without a need for underlying system libraries or node changes. I don’t know that landscape very well but I am almost certain there are other ways to achieve your goal :slight_smile:

It’s not that I don’t want to make a PR, it’s more than I have no idea which PR I should make.

Anyway, I used a workaround for this little use case with one single language: