ECMAScript Internationalization API - Intl

From WikiMLT
Revision as of 21:27, 21 March 2023 by Spas (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Intl ob­ject is the name­space for the EC­MAScript In­ter­na­tion­al­iza­tion API, which pro­vides lan­guage sen­si­tive string com­par­i­son, num­ber for­mat­ting, and date and time for­mat­ting. The Intl ob­ject pro­vides ac­cess to sev­er­al con­struc­tors as well as func­tion­al­i­ty com­mon to the in­ter­na­tion­al­iza­tion con­struc­tors and oth­er lan­guage sen­si­tive func­tions.

Video 1. Web Dev Simplified on YouTube: Formatting Is So Easy With The Intl JavaScript API.
Video 1. Web Dev Sim­pli­fied on YouTube: For­mat­ting Is So Easy With The Intl JavaScript API.

Ref­er­ences

Sim­ple ex­am­ple

const formatter = new Intl.RelativeTimeFormat("bg-BG", { style: "long" });
formatter.format(-1, "minute");
'преди 1 минута'