Coder Social home page Coder Social logo

Comments (8)

anba avatar anba commented on June 17, 2024 2

The correct results are:

js> addIntlExtras(Intl) // Add Intl.Locale to Intl in SpiderMonkey shell
js> (new Intl.Locale("en-u-kf-true")).caseFirst
""
js> (new Intl.Locale("en-u-kf-mom")).caseFirst  
"mom"

The caseFirst result for "en-u-kf-true" is the empty string, because the tag is first canonicalised to "en-u-kf" per BCP 47 Language Tag to Unicode BCP 47 Locale Identifier and 3.2.1 Canonical Unicode Locale Identifiers which states:

Any type or tfield value "true" is removed.

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on June 17, 2024

I think this is a reasonable behavior tbh.

We verify that the input language identifier string is well formed while we verify that the options are valid.

We're consistent in that behavior.

Long time ago we talked about an option to validate the input string as well, but that never came to fruition.

from proposal-intl-locale.

FrankYFTang avatar FrankYFTang commented on June 17, 2024

then
What should the expected result of
(new Intl.Locale("en-u-kf-true")).caseFirst and
(new Intl.Locale("en-u-kf-mom")).caseFirst ?

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on June 17, 2024

(new Intl.Locale("en-u-kf-true")).caseFirst

undefined

(new Intl.Locale("en-u-kf-mom")).caseFirst

undefined

I'm not opposed to liberating options to be well-formed only, in which case we'd also accept caseFirst = "mom" and just not apply it since it's not valid.
That would be forward compatible, but I'm not sure if consistency is more important than feedback to users.

The reason why I think the current subset makes sense (until we complete it) is that options come from developers, so throwing on well-formed, but invalid value makes sense.
langid strings come from some external sources, browser, system etc. If they contain errors, rejecting them should be last resort, because user can rarely do anything about it, and the dev usually cannot do anything.

from proposal-intl-locale.

FrankYFTang avatar FrankYFTang commented on June 17, 2024

(new Intl.Locale("en-u-kf-true")).caseFirst

undefined

(new Intl.Locale("en-u-kf-mom")).caseFirst

undefined

Why, according to the current spec, the result is not "true" and "mom" ? That is the part I try to understand.

I'm not opposed to liberating options to be well-formed only, in which case we'd also accept caseFirst = "mom" and just not apply it since it's not valid.

I am not lobbying for that. Just try to figure out what the current spec said.

That would be forward compatible, but I'm not sure if consistency is more important than feedback to users.

The reason why I think the current subset makes sense (until we complete it) is that options come from developers, so throwing on well-formed, but invalid value makes sense.
langid strings come from some external sources, browser, system etc. If they contain errors, rejecting them should be last resort, because user can rarely do anything about it, and the dev usually cannot do anything.

from proposal-intl-locale.

littledan avatar littledan commented on June 17, 2024

We last discussed this topic in #19 . There, we decided to validate simply the grammar, and not the contents, in these contexts. Applying that decision here, I think we should return "mom" and "true", as the current specification does, while continuing to be more strict in the options bag. (EDIT: @anba has the correct answers below)

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on June 17, 2024

Based on my read of the current spec and @anba's description, it seems like the current spec is correct and the behavior is as expected.

Is it ok for me to close this issue?

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on June 17, 2024

reopen if needed!

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.