Problem with formatting date according to locale
Hello. In my project, I am trying to format my dates accordingly to the user locale.
I've been struggling with getting the result I want, only being able to render it correctly for the 'en' locale.
I found this pretty simple example:
When testing on this specific playground, changing the locale was working but, when I tried to implement it directly on my project, if I replace it per example to 'pt-PT', the output, instead of being
6 de dezembro de 2023is
2023 M12 6
Any bit of information as to why I'm getting this behaviour would be highly appreciated. Thank you in advance
hi! i am not sure if the
pt-PTis valid IANA registered locale, but i guess the
Intlapi allows it and considered it valid, but FYI think the 100% IANA name is
pt-BR, just mentioning because i am not sure if using a non-standard locale has different meaning per computer.
what node.js version are you using? the playground ships with nodejs
18.16.1, i ask this because different node.js version has a different set of the
Intlapi available, i mean that older versions of node.js does not comes with all the locales built-in.
I've tried either 'pt-PT', 'pt-BR', 'es-ES', 'fr-FR' and the result is always in this format
2023 M12 7
I am using node
I'm just confused as to why
Intlis working on that playground I sent with the locale examples I gave you, but on my project, is formatting differently
@miyazk4 i get correct results also on my local machine (macos Sonoma Apple Silicon M1)
it seems to me that for some reason your node.js does not come with full icu support so therefore the locale you are specifying is not supported. it is weird because the full icu is the default but maybe it has to do because the way you installed node.js. how did you installed it?
anyway, you can read the node.js Internationalization docs and get some instructions about how to troubleshoot this. you can try passing explicitly to node.js that cli arg
--with-intl=full-icu, or you may need to install the full-icu package like described in the node.js guide.
I believe I have full icu support, as this problem is only happening when I am running my project locally. If I try it on the playground, it shows as expected, as well if I'm testing on the console, etc
It just appears to be a problem when running jsreport locally, could I be lacking some config or something?
Either way, I will check up the link that you sent me and look into this a bit more. Thank you!