Giter VIP home page Giter VIP logo

Comments (2)

sukima avatar sukima commented on May 29, 2024 1

In regards to ICU Message syntax what would you expect The number is: {nonexistent} to look like?

That said I did a little research and found that per the ECMAScript specs that the value is anything as it will be coerced to a number (defaulting with undefined).

I didn't look up the other formats. But it seems to me that it is safe to assume value is not a required parameter. It may be weird to have the format convert to NaN or something but I presume that is what is expected?

from ember-intl.

sukima avatar sukima commented on May 29, 2024 1

I did a little more research:

Spec Expectation Interpretation
11.5.5 DateTime Format Functions If date is not provided or is undefined, then Let x be ! Call(%Date.now%, undefined). Else, Let x be ? ToNumber(date). Do not assert value
15.5.2 Number Format Functions If value is not provided, let value be undefined. Let x be ? ToNumeric(value). Do not assert value
13.5.3 FormatList list (which must be a List of String values) Must assert value

Since format-message uses the above internal implementations their expectations should be the same (i.e. do not assert). Also since lists are the only one I found that does need an assertion and that the ICU message syntax does not provide for lists it is reasonable that the format-message also should not assert values.

I am uncertain about the utility of allowing dynamic messages for format-message in app code instead perhaps using some alternative pattern that guarantees the existence of the value passed in (like hard coded strings or constants).

As for format-list the ICU guides recommend its use outside the message formatting:

Format the parameters separately (recommended)
You can format the parameter as you need before calling MessageFormat, and then passing the resulting string as a parameter to MessageFormat.
This offers maximum control, and is preferred to using custom format objects (see below).
~ https://unicode-org.github.io/icu/userguide/format_parse/messages/index#format-the-parameters-separately-recommended

Which I interpret that we should to the following with lists:

{{t "" items=(format-list items)}}

from ember-intl.

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.