Coder Social home page Coder Social logo

Comments (2)

littledan avatar littledan commented on September 24, 2024

Aside from including unsupported options, resolvedOptions().locale is currently pretty strict about only including the extensions that are in the locale itself, and not things that are specified via the options bag. I wonder if this might come up in practice, e.g.,

let formatter = new Intl.DateTimeFormat("zh", { calendar: "chinese" });
if (formatter.resolvedOptions().locale !== "zh") alert("Please upgrade to a browser supporting Chinese");

This code would "break" if locale switched to being zh-u-ca-chinese, while it currently "works".

So, I'm thinking to try to preserve the current semantics of resolvedOptions().locale (modulo bugs) for formatters (including new formatters) while simultaneously organizing the specification to be based around creating inner Intl.Locale objects (to remove the multiple parallel paths for locale processing).

from proposal-intl-locale.

littledan avatar littledan commented on September 24, 2024

Oops, that above example doesn't actually apply because calendar as something in the options bag isn't supported yet (see tc39/ecma402#175). There are other extension keys in options which do make it in, like kf, but those differ across browser in their level of support (as the spec explicitly allows) so they may not be so useful.

Aside from how minimal the string is, there's another mismatch: ResolveLocale uses locale data to determine things like the default calendar, and this shows up in resolvedOptions. Presumably we don't want to do this for Intl.Locale by default (though it could be a feature of maximize()). It's looking a bit tricky to refactor the specification code to be one thing in terms of the other while actually reducing duplication.

from proposal-intl-locale.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.