Coder Social home page Coder Social logo

Comments (9)

zbraniecki avatar zbraniecki commented on September 23, 2024

BCP47 separated "valid" and "well-formed". I'd like us to support "well-formed" here.

That means that your example of "en-u-nu-!@-#asdf" will not work because it doesn't match:

extension = singleton 1*("-" (2*8alphanum))

but, en-u-nu-foo should parse and I believe in result new Intl.Locale('en', {'numberingSystem': 'foo'}) should as well.

from proposal-intl-locale.

anba avatar anba commented on September 23, 2024

new Intl.Locale("en", {hourCycle: "h99"}) currently throws a RangeError, should this also be changed?

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 23, 2024

I believe so. @littledan @srl295 ?

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 23, 2024

My intention here is that we should not cap the values that are well-formed and potentially supported by some language tag parsing code just because our APIs don't support a certain value.

For example, maybe at some point UTS will add hc-h28 and maybe ECMA242 will not support it for a while. That doesn't mean that Intl.Locale must reject such code.
A user may use Intl.Locale to compare/retrieve language or script portion of the tag, but keep carrying such a language tag around because some part of their code actually recognizes h28 as a valid hourCycle.
So, yeah, I'd suggest we stick to well-formed for this API.

from proposal-intl-locale.

anba avatar anba commented on September 23, 2024

(Note: Updated the issue description to note a possible problem with the third choice.)

from proposal-intl-locale.

littledan avatar littledan commented on September 23, 2024

I'm not sure if ICU contains an API for this validation, cc @jungshik . The question here is closely related to that in tc39/ecma402#175 (comment) though we may decide to answer it differently if Intl formatters are validating and Intl.Locale is not.

With the patch in Intl.Locale currently as well as tc39/ecma402#175 , the logic for validating options is something like, "if it's from a small, fixed set, check that it is in that set; otherwise, treat it as uninterpreted data and permit any value". I can see how this is inconsistent, especially if hourCycle may get more values in the future.

For that reason, option 2 seems good to me. But, if we go with that, maybe we want to perform similar validation in existing Intl constructors. Or should we continue to omit the validation for compatibility?

Seems like we should discuss this issue in the Intl VC call.

from proposal-intl-locale.

anba avatar anba commented on September 23, 2024

I'm not sure if ICU contains an API for this validation

The following functions should probably fit our needs:

  • unumsys_openAvailableNames to retrieve all known numbering systems.
  • ucol_getKeywordValues to retrieve all known collation types.
  • And for the calendar types we probably need to use ucal_getKeywordValuesForLocale with commonlyUsed = false.

Plus uloc_toUnicodeLocaleType to convert the values to BCP 47 Unicode extension types.

from proposal-intl-locale.

littledan avatar littledan commented on September 23, 2024

We discussed this issue in the Intl meeting, and the group consensus was to validate just the grammar, as @anba's patch ended up doing.

from proposal-intl-locale.

littledan avatar littledan commented on September 23, 2024

Fixed by #23.

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.