Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Use Globalize with Ecma-402 #532

Open
2 tasks
rxaviers opened this issue Oct 10, 2015 · 3 comments
Open
2 tasks

Docs: Use Globalize with Ecma-402 #532

rxaviers opened this issue Oct 10, 2015 · 3 comments

Comments

@rxaviers
Copy link
Member

We should provide examples demonstrating how certain modules (e.g., message, relative time, unit formatters) could be used along with Ecma-402.

💥 It's important to highlight that such mixture of libraries will decrease the supported browsers (or will require user to polyfill when needed).

I think this topic deserves presence in the main documentation (REDAME.md) and specific examples inside of each of the mentioned modules.

Requires:

Examples:

var ecmaNumberFmt = Intl.NumberFormat( "en" );

Globalize.loadMessages({
  en: {
    task: [
      "You have {count, plural,",
      "     =0 {no tasks}",
      "    one {one task}",
      "  other {{formattedCount} tasks}",
      "} remaining"
    ]
  }
});

taskFormatter = Globalize( "en" ).messageFormatter( "task" );

taskFormatter({
  count: 0,
  formattedCount: ecmaNumberFmt( 0 )
});

var relativeTimeFormatter = Globalize( "en" ).relativeTimeFormatter(  "month", {
  numberFormatter: ecmaNumberFmt
});

var unitFormatter = Globalize( "en" ).unitFormatter(  "month", {
  numberFormatter: ecmaNumberFmt
});

Ref #399

@jzaefferer
Copy link
Contributor

The example looks good.

As for module-specific docs, I think those would only have to mention ECMA-402 when formatter instances are passed as arguments, as those don't need to be Globalize formatters.

@rxaviers
Copy link
Member Author

As for module-specific docs, I think those would only have to mention ECMA-402 when formatter instances are passed as arguments, as those don't need to be Globalize formatters

Sure. 👍

@modellking
Copy link

modellking commented Oct 18, 2021

Hello 👋

(I am currently planning our approach of i18n+l10n for a mid-size SPA and did only find this ticket searching exactly the proposed addition to the docs)

Is the approach from the Example compatible with the globalize-compiler?
What are the non-trivial cases of using this? Date was mentioned and I presume Message is impossible at the moment.

Edit: Nvm guys; found out formatjs uses those by default and our team should be able to work around the different structure of the message parser integration over there. Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants