Issue
I am struggling with dates right now. I have an express app with node and I use date.toLocaleDateString('fr', {"month": "long"})
to convert dates into human readable dates, with French locale.
It is working fine on my local computer (Mac 10.12.2) but when I pushed the website to a Debian 8 server, it seems to not support the locale.
Expected result (and result on my computer) : 15 décembre 2016
Actual result : 2016 M12 15
.
However, when I set the locale to English, the date is properly displayed which make me think the French locale is not supported/installed/connected to node.
Here are the results of some commands :
$ locale
LANG=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE=fr_FR.UTF-8
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=
$ node -pe process.versions.icu
57.1
Do you have any idea to solve this issue ? Thank you for your help !
Solution
This is how Node.js is built. By default only the en_US is bundled within node itself in order to make Node.js lighter. If you want to support other locales you need to build your own version of node with the correct icu
flags (see here https://nodejs.org/api/intl.html) or, you can add this npm package to your project https://github.com/unicode-org/full-icu-npm, but it will grow the deployment package by about 50MB...
Answered By - DraganescuValentin Answer Checked By - Timothy Miller (WPSolving Admin)