facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.41k stars 596 forks source link

Using Intl with standalone Hermes app #1350

Open manuelpuyol opened 2 months ago

manuelpuyol commented 2 months ago

👋 I've been experimenting running JS using Hermes as a standalone binary in Linux and wanted to use Intl.DateTimeFormat, but looks like Intl support is tied to Android/iOS runtimes.

Is there any way to use Intl in a Linux runtime without having to use polyfills?

I created this simple gist to reproduce the current Intl behavior https://gist.github.com/manuelpuyol/dbb1e41c748dbaf80da3ca3556648611

neildhar commented 2 months ago

Hey @manuelpuyol, we're aware of this limitation, and have a plan to address Intl support more comprehensively in the future by migrating to ICU (see #1211). Once we do that, we will be able to support Intl across platforms, including in a standalone linux application.

In the interim, if you're up for getting your hands dirty, Microsoft maintains an implementation for Windows that is also based on ICU (see here). It should be possible to pull in that implementation and port it to work on Linux. We would also welcome a PR to make this change in Hermes, since migrating to ICU is part of our plan for Intl support.

manuelpuyol commented 2 months ago

great! thanks for pointing that windows implementation, I'll take a look and see if that's something I can PR!