Skip to content

Intl v1.0.0

Choose a tag to compare

@ammarahm-ed ammarahm-ed released this 05 Sep 05:15
· 128 commits to main since this release

ECMA-402 Intl for @react-native-quickjs/quickjs,
backed by the operating system's own CLDR database the way Hermes does — no locale data ships in your bundle and none ships in this package.

npm install @react-native-quickjs/intl

An app that installs it needs no other Intl polyfill.

What it provides

Intl.DateTimeFormat · Intl.NumberFormat · Intl.Collator ·
Intl.PluralRules · Intl.RelativeTimeFormat · Intl.ListFormat ·
Intl.DisplayNames · Intl.Segmenter · Intl.Locale ·
Intl.DurationFormat · Intl.getCanonicalLocales · Intl.supportedValuesOf

plus the ECMAScript-side methods that must route to the same backend:
Number.prototype.toLocaleString, BigInt.prototype.toLocaleString,
Array.prototype.toLocaleString, %TypedArray%.prototype.toLocaleString,
String.prototype.localeCompare and its toLocaleUpperCase/toLocaleLowerCase,
and Date.prototype.toLocaleString/toLocaleDateString/toLocaleTimeString.

How it works

  • Algorithm in JS, data in the OS. BCP-47 parsing, option resolution and its getter order, locale negotiation, resolvedOptions, and the class shapes are written once in js/intl.js, byte-identical on every platform. The CLDR data is reached through a narrow platform seam (cpp/IntlPlatform.h) into what iOS and Android already carry.
  • Lazy. Installing defines one accessor on globalThis; reading Intl materializes the implementation and redefines it as a data property. An app that never reads Intl pays one property access.
  • Bytecode. js/intl.js is compiled to QuickJS bytecode at build time against the same engine revision, so materialization costs no parse.
  • Real classes. Ordinary JavaScript classes, so new, instanceof, .prototype and subclassing work.