pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Other locales than english are not supported in pkg generated executables

Open SpraxDev opened this issue 2 years ago • 2 comments

What version of pkg are you using?

5.5.2

What version of Node.js are you using?

16.13.0

What operating system are you using?

Debian GNU/Linux 11 (bullseye)

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node16-win-x64, node16-linux-x64

Describe the Bug

I am using functions that are part of Node.js and accept a locale to be provided. So when I do new Date().toLocaleDateString('de-DE', {weekday: 'long'}) I expect the output to be Montag instead of Monday.

But for some reasons Node.js inside the executable generated by pkg does not contain other locales and falls back to English instead.

This causes some nasty bugs that haven't been caught by my tests. This affects Intl.NumberFormat and probably all the other methods too.

Expected Behavior

To support other locales like de(German) like it would if Node.js is installed normally on a system

To Reproduce

  1. Create a index.js file (empty directory) with:
console.log(Intl.NumberFormat.supportedLocalesOf('de'));
console.log(Intl.NumberFormat.supportedLocalesOf('de-DE'));
console.log(Intl.NumberFormat.supportedLocalesOf('xx'));
console.log(new Date().toLocaleDateString('de-DE', {weekday: 'long'}));
  1. Run npx pkg -t node16-linux-x64 index.js

  2. Run ./index and node ./index.js

You should see different outputs (this happens on node16-win-x64 too)

SpraxDev avatar Mar 28 '22 13:03 SpraxDev

This seems to be related to this issue: https://github.com/vercel/pkg/issues/1563

MaxMediaPictures avatar Apr 05 '22 08:04 MaxMediaPictures

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Jul 05 '22 00:07 github-actions[bot]

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Oct 04 '22 00:10 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar Oct 10 '22 00:10 github-actions[bot]

For reference #1731 #1749

TBG-FR avatar Oct 20 '22 14:10 TBG-FR

Here's a working example/solution to get correctly formatted dates with pkg : https://github.com/vercel/pkg/issues/1731#issuecomment-1317191357

TBG-FR avatar Nov 16 '22 15:11 TBG-FR