For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/i18n/intl.md.

Use Intl

Lynx has no Intl where your app runs. Turn on the APIs your code uses, and code that formats, names or sorts by locale works as it does in a browser.

Why you need it

Without Intl:

  • new Intl.DisplayNames() throws on a phone, while your tests, which run in Node, pass.
  • toLocaleString() ignores the locale. It formats numbers the en-US way, and dates as 01/15/2026, 01:05:09 PM.
  • localeCompare() compares character codes, so 'é' sorts after 'z'.

Turn it on

List the Intl APIs your code uses in the build's intl option:

angular.json
"build": {
  "builder": "@blotch/angular-lynx-build:application",
  "options": {
    "intl": ["DisplayNames", "NumberFormat", "Collator"]
  }
}

Then install the FormatJS polyfills they use. The build stops and lists the ones that are missing. For the three above:

npm install @formatjs/intl-getcanonicallocales @formatjs/intl-locale @formatjs/intl-displaynames @formatjs/intl-numberformat @formatjs/intl-pluralrules

The build adds them to the bundle for iOS and Android, before your code, on both threads. The web preview uses the browser's own Intl, so its bundle doesn't change.

Code you share with a web app then works as it is:

src/app/countries.ts
export const regionName = (code: string, locale: string): string =>
  new Intl.DisplayNames([locale], { type: 'region', fallback: 'none' }).of(
    code,
  ) ?? code;

export const sortedCountries = (codes: string[], locale: string) =>
  codes
    .map((code) => ({ code, name: regionName(code, locale) }))
    .sort((a, b) => a.name.localeCompare(b.name, locale));

The build tells you what's missing

When your code, or a package it uses, needs an Intl API that intl doesn't list, the build prints a warning for it, with the files and the entry to add:

⚠ Intl.PluralRules is used in src/app/cart.ts, but Lynx has no Intl where the app runs, so it throws "Intl is not defined" on the device. To fix it, add "PluralRules" to the intl build option (in angular.json, or pluginAngularLynx({ intl })). If the code never runs on Lynx, set "intlChecks": "off".

It looks at the code that goes into the bundle for iOS and Android, on both threads, and warns about:

  • The Intl constructors an entry adds, such as new Intl.PluralRules() or Intl.NumberFormat(). Without Intl they throw.
  • The locale methods given what Lynx ignores: toLocaleDateString() and toLocaleTimeString() with a locale or options, localeCompare() with a locale or options, and toLocaleString() with options other than minimumFractionDigits, maximumFractionDigits and useGrouping, or with a locale that isn't English. These don't throw. They format the fixed way listed above.

It leaves out:

  • Code behind a feature check: in a file that tests for Intl (typeof Intl !== 'undefined', 'Intl' in globalThis), or for one of its APIs (typeof Intl.PluralRules === 'function'), it reports nothing for what the file checks.
  • Calls whose arguments are variables, such as n.toLocaleString(locale, options), since the build can't tell what they hold.
  • Angular's pipes, which don't use Intl (see Angular's pipes), and the web preview, whose browser has Intl.
  • toLocaleString() with only a locale, once the build adds NumberFormat or DateTimeFormat. The build can't tell whether it's called on a date or a number, so either counts for it, including a NumberFormat added for another entry: RelativeTimeFormat and DateTimeFormat add it (see what each entry adds). With only NumberFormat or RelativeTimeFormat listed, date.toLocaleString('de-DE') isn't reported, and on the device it still formats the date the fixed way. If you format dates like that, add DateTimeFormat too.
  • Everything, in a build with Rsbuild's persistent cache (performance.buildCache). The build doesn't read a cached module again, so rather than report only the modules that changed, it reports nothing, even with "intlChecks": "error". Turn the cache off for a build you rely on the check for, such as a release.

A package's file counts when it's in the bundle, even if your app never calls the function in it that uses Intl. If the code never runs on a phone, turn the check off.

Make it an error, or turn it off

The intlChecks build option sets how the build reports them:

angular.json
"options": {
  "intlChecks": "error"
}
  • "warning", the default: prints them, and the build passes.
  • "error": fails the build. A build with Rsbuild's persistent cache isn't checked (see above).
  • "off": prints nothing.

Without the Angular CLI, pass pluginAngularLynx({ intlChecks: 'error' }).

What each entry adds

intl entryAddsPackage
CollatorIntl.Collator, and localeCompare() with locales and optionsNone: AngularLynx's own (see Sorting)
DateTimeFormatIntl.DateTimeFormat, and toLocaleString(), toLocaleDateString(), toLocaleTimeString() on dates@formatjs/intl-datetimeformat
DisplayNamesIntl.DisplayNames: the names of regions, languages, scripts and currencies@formatjs/intl-displaynames
ListFormatIntl.ListFormat@formatjs/intl-listformat
NumberFormatIntl.NumberFormat, with compact, currency, percent and unit styles, and toLocaleString() on numbers@formatjs/intl-numberformat
PluralRulesIntl.PluralRules@formatjs/intl-pluralrules
RelativeTimeFormatIntl.RelativeTimeFormat ("in 3 days")@formatjs/intl-relativetimeformat

Every entry also needs @formatjs/intl-getcanonicallocales and @formatjs/intl-locale. They add Intl.getCanonicalLocales() and Intl.Locale.

Some entries need others too, which the build adds for you:

  • NumberFormat uses PluralRules.
  • DateTimeFormat and RelativeTimeFormat use NumberFormat.

Locales

  • The build adds the data of your app's locales: i18n.sourceLocale and each locale in i18n.locales in angular.json. One bundle serves every language, so it holds them all.
  • A locale FormatJS has no data for gets a warning, and formats in your source locale.
  • Without a locale, as in new Intl.NumberFormat() or n.toLocaleString(), they use the phone's language (appLocale) when it's one of your locales. Otherwise they use your source locale. That's how provideLocale() picks Angular's LOCALE_ID.
  • In Lynx Explorer, which sends no appLocale, it's always your source locale.

Time zones

Dates format in the phone's time zone, as in a browser. The build reads the zone's offsets from the device's clock, summer time included.

The apps ng build --platform makes also send the zone's name as appTimeZone. So resolvedOptions().timeZone is, for example, 'Europe/Paris', and timeZoneName: 'long' gives Central European Summer Time.

Lynx Explorer sends no name. There the zone is 'Etc/Unknown', and its name shows as an offset, such as GMT+02:00.

Other time zones

timeZone: 'UTC' and offsets such as timeZone: '+05:30' work as they are. Other zones, such as timeZone: 'America/New_York', need FormatJS's time zone data. Add it to polyfills:

angular.json
"polyfills": ["@formatjs/intl-datetimeformat/add-golden-tz.js"]

It adds about 1.6 MB to the bundle, and to the web preview's too, where it does nothing.

Sorting

FormatJS has no Intl.Collator, so the Collator entry is AngularLynx's own.

When you build, it asks Node how each of your locales orders text. Node has the full ICU library browsers sort with. The build asks about:

  • the letters of Latin, Greek, Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Thai and Japanese kana
  • punctuation and symbols
  • their accents and cases

Then it sorts with that, as the Unicode Collation Algorithm does: by letter, then accent, then case. It supports:

  • Each language's own letters, such as Swedish ä after z, Spanish ñ after n and Czech ch after h
  • The options numeric, sensitivity, caseFirst and ignorePunctuation

On every pair of 120 test words in 10 languages, it orders them as Node does.

What's approximate

  • Chinese, Japanese and Korean ideographs and syllables sort after the other scripts, by Unicode code point. There's no pinyin or stroke order.
  • Contractions of three letters or more, such as Hungarian dzs, sort as their letters. So do Thai's vowels that come before a consonant.
  • Text written as a letter plus a separate accent (a + U+0308) sorts as the letter, in a language that makes the accented letter one of its own, as Swedish does ä. A phone's keyboard types an accented letter as one character, so this is rare.
  • usage: 'search' compares as 'sort' does.
  • The collation option ('phonebk', 'pinyin') is ignored: resolvedOptions().collation is always 'default'.

Bundle size

Intl data is large, so add only what your code uses. Each API's code and data go into both threads' halves of the bundle, so they count twice in its size.

Measured as what each adds to the iOS and Android bundle:

intl entryAdds, with one localeAdds for each more locale
Collator630 kBUp to 40 kB, for a language that orders its letters its own way, such as Swedish
ListFormat637 kB3 kB
PluralRules663 kB3 kB
DisplayNames781 kB136 kB
NumberFormat (with PluralRules)933 kB170 kB
RelativeTimeFormat (with NumberFormat)982 kB186 kB
DateTimeFormat (with NumberFormat)1.79 MB722 kB
All seven2.15 MBAbout 850 kB

About 550 kB of each is the same code: Intl.Locale and Intl.getCanonicalLocales, with their data. So two entries add less than their sum.

If the bundle outgrows the initial budget in angular.json, raise it.

Angular's pipes

Angular's DatePipe, DecimalPipe, CurrencyPipe, PercentPipe and I18nPluralPipe don't use Intl. They format with the locale data you register with registerLocaleData(), for the LOCALE_ID that provideLocale() sets.

So they work without the intl option, and the option doesn't change them. For each locale:

  • Register Angular's data for the pipes.
  • List the locale in i18n.locales for code that calls Intl.

Both follow the phone's language the same way.

Without the Angular CLI

If you run RSpeedy yourself, or your build target in angular.json isn't AngularLynx's, pass the same list to the plugin in lynx.config.ts:

lynx.config.ts
import { defineConfig, pluginAngularLynx } from '@blotch/angular-lynx-build';

export default defineConfig({
  plugins: [pluginAngularLynx({ intl: ['DisplayNames', 'NumberFormat'] })],
});