Coder Social home page Coder Social logo

Comments (2)

caridy avatar caridy commented on May 19, 2024

Ok, let me try to address does one at a time:

  • the low level API already exists, you can do Intl.DateFormat(), you can also use intl-messageformat module to implement what in the future could be Intl.MessageFormat() using ICU format. In general, those low level APIs are ok, but, there are few implications that a higher level API will help to address, which is what react-intl, handlebars-helper-intl and dust-helper-intl are trying to do. If you look at src/component.js, you will see that it uses the low level APIs under the hood.
  • react components will require ICU messages to be available to format them using the props, but those messages are bound to a locale, and same for formatters. the best way we have found to accommodate this is by sharing messages and formatters between react components as part of the composition process, that's what this mixin does it. You call for render on the top level component, you pass all messages, formatters, the the locale, and it makes those available for every child component, so you don't have to propagate the messages thru props.
  • it does depends on react context to propagate messages, formatters and locales so child components can use them.
  • formatting a date, a number, or a message is an expensive operation (even when using the native implementation in chrome, firefox, or any other browser that supports ECMA402), this abstraction adds a level of caching that improves the formatting process drastically (we are talking order of magnitud faster).

I understand that having standalone libraries and global structures for messages, locales and formatters could work just fine, but complex apps with tons of components and translation per component by professional translators will require some sort of coupling between components and the messages, including some sort of validation processes, and that's what this mixin is doing. If a component brings the mixin into the definition, it means it will require some machinery under the hood to guarantee that messages, formatters and locales are in place to facilitate the rendering of those messages.

from formatjs.

AlexGalays avatar AlexGalays commented on May 19, 2024

Alright!

from formatjs.

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.