Skip to content

Intl.Locale #106

Closed
Closed
@zbraniecki

Description

This is the second spin-off from #68.

Proposing a new class Intl.Locale which creates objects with a list of extension keys used by any of the formatters and with toString method which produces a BCP47 locale string with relevant extension keys.

Examples:

let locale = new Intl.Locale('en-US');
locale.toString(); // 'en-US'
locale.calendar; // undefined
let locale = new Intl.Locale('en-US', {
  ca: 'buddhist'
});
locale.toString(); // 'en-US-u-ca-buddhist'
locale.calendar; // 'buddhist'
let locale = new Intl.Locale('en-US-u-ca-buddhist');
locale.toString(); // 'en-US-u-ca-buddhist'
locale.calendar; // 'buddhist'
let locale = new Intl.Locale('en-US-u-ca-buddhist', {
  ca: 'gregory'
});
locale.toString(); // 'en-US-u-ca-gregory'
locale.calendar; // 'gregory'
let locale = new Intl.Locale('en-US-u-ca-buddhist', {
  ca: 'gregory'
});
locale.toString(); // 'en-US-u-ca-gregory'
locale.calendar; // 'gregory'

Proposed list of supported extension keys and their option key names:

  • ca-- calendar
  • nu -- numberingSystem
  • hc -- hourCycle
  • tz -- timeZone
  • cu -- currency
  • co -- collation
  • kn -- numeric
  • kf -- caseFirst

Looking for feedback

Metadata

Assignees

No one assigned

    Labels

    c: localeComponent: locale identifierss: in progressStatus: the issue has an active proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions