ECMAScript Internationalization API Specification

repository·main·Indexed 20 days ago

https://github.com/tc39/ecma402

The formal specification for the ECMAScript® Internationalization API (Intl), including documentation for locale-sensitive operations, text segmentation (Intl.Segmenter), relative time formatting, and list formatting. This repository contains the source for the specification and the @tc39/ecma402-biblio package for machine-readable terms, clauses, and grammar.

Tokens
65.1K
Snippets
77
Records
442
Agent score
67%

What's inside ECMA-402

  1. Overview of active Intl proposals

    main

    The ECMA-402 specification includes several active proposals for internationalization APIs. Key upcoming or evolving APIs include:

    • Intl.ListFormat: For formatting lists of items (e.g., 'apples, oranges, and bananas').
    • Intl.Locale: For representing and manipulating BCP 47 language tags.
    • Intl.RelativeTimeFormat: For formatting relative time expressions (e.g., '2 days ago').
    • Intl.NumberFormat Unified API: A proposal to unify various number formatting capabilities.
    • Intl.Segmenter: For segmenting strings into units like words, sentences, or graphemes.
    • Intl.DisplayNames: For providing localized names for language, region, script, and calendar identifiers.
  2. Overview of ECMA-402 (Intl) Proposals and Status

    main

    The ECMA-402 (Internationalization) specification is a collection of APIs designed to handle locale-sensitive operations. The project evolves through TC39 stages. Based on recent discussions, the following APIs are identified by their development status:

    Stage 3 (Stable/Near-Stable)

    • Intl.Segmenter: Used for breaking text into units like graphemes, words, or sentences. Note that implementations may significantly increase bundle size due to dictionary requirements.
    • Intl.RelativeTimeFormat: Used for formatting relative time expressions (e.g., "2 days ago").

    Stage 2 (Refining)

    • Intl.ListFormat: Used to join items in a list with appropriate conjunctions and punctuation (e.g., "A, B, and C").

    Stage 1 (Early Proposal)

    • Intl.UnitFormat: For formatting units.
    • dateStyle / timeStyle options: High-level options for DateTimeFormat to express user intent (e.g., short, long, normal).
    • Intl.IntervalFormat and Intl.DurationFormat.
  3. Status of Intl.ListFormat (Stage 3)

    main

    The Intl.ListFormat proposal is currently at Stage 3. It is used for formatting a list of items into a human-readable string (e.g., using commas and conjunctions).

    Current Status:

    • Implementation is available in SpiderMonkey (behind a flag).
    • Known issues include a bug with type: 'disjunction' in Spanish.
    • Test262 tests and MDN documentation are considered good.
  4. Status of DurationFormat Proposal

    main
    The DurationFormat proposal is undergoing an extensive refactor to decouple numeric type handling from other types, which simplifies the PartitionDurationFormatPattern. This change aims to improve the structure of the proposal. Additionally, a Google Summer of Code project has been approved to implement DurationFormat in ICU4X.
  5. Status of Intl.DisplayNames (Stage 3)

    main

    The Intl.DisplayNames proposal is at Stage 3. It is used to get localized names for various identifiers.

    Current Status:

    • A calendar option has been added to allow getting names for month, weekday, quarter, and dayPeriod within a specific calendar context.
    • Work is ongoing to address how to access leap months.
  6. Status of Intl.DurationFormat proposal

    main
    The Intl.DurationFormat proposal is currently at Stage 2. The working group is working towards moving it to Stage 3 by addressing pending specification points and validating requirements with implementers. Reaching Stage 3 is expected to allow for necessary updates to ICU (International Components for Unicode) to support the feature.
  7. Status of Intl.DisplayNames (Stage 2)

    main

    The Intl.DisplayNames proposal is currently at Stage 2. It is used to get localized names for language, region, script, and other identifiers.

    Current Status:

    • A recommendation has been made to use camelCase for API options to ensure consistency with JavaScript patterns and to allow the output of one API to be used as the input for another.
  8. Status of Intl.DateFormat.prototype.formatRange (Stage 3)

    main

    The formatRange proposal for Intl.DateTimeFormat is at Stage 3. It allows formatting a range of dates/times.

    Current Status:

    • V8 (Chrome) has shipped this.
    • Test262 tests are complete.
    • MDN documentation includes interactive examples for formatRange, while formatRangeToParts is pending merge.
  9. Status of Intl.RelativeTimeFormat (Stage 3)

    main

    The Intl.RelativeTimeFormat proposal is currently at Stage 3. It is used for formatting relative time expressions (e.g., "2 days ago").

    Current Status:

    • formatToParts() has landed in nightly builds.
    • Implementation is expected in Firefox (beta in September, release in October).
    • Test262 tests are passing.
    • MDN documentation is available.