globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

App example using webpack: Make it more interactive #489

Open rxaviers opened 9 years ago

rxaviers commented 9 years ago

Allow user to change number, currency, and the number of remaining tasks for the pluralization example.

This issue has been motivated by @sompylasar comment:

Maybe for the demo purposes also increment the count from 0 to some number and back to 0? This would demonstrate how plurals work with different values.

sotojuan commented 9 years ago

Been working on this, it's not super pretty but it works.

I'm taking a look at the style guide now, but if this looks good I can submit the PR.

sotojuan commented 9 years ago

Update: I moved the inputs to the table and added relative time and date format:

Let me know how this looks!

rxaviers commented 9 years ago

@sotojuan this is looking great. Although, note the following.

When we change the formatter value only (e.g., changing the number in the first example), we use the same formatter to format various values, which is great. When we change the formatter options (e.g., changing the currency code, date pattern, or relative time unit), we are actually using different formatters, not reusing a formatter, which has its consequences: while it works just fine in development mode, where you can generate any formatter, it won't work in production mode, where it's expected that the formatter be compiled and available.

To make long story short, make dynamic the formatter values only, i.e.:

Does it sound good?

Thanks so far!

PS: Note you can make the relative time or patterns dynamic, but that would require a code analogous to https://github.com/jquery/globalize/pull/481#issuecomment-140340869.

sotojuan commented 9 years ago

Gotcha, I made the following changes:

Let me know how this looks! I just need to handle bad inputs, add some comments, and look at the style guide again.

rxaviers commented 9 years ago

@sotojuan sorry for my delayed answer, it looks better. From the picture above, I read Change format, but I guess it's only a matter of updating the button title to Change date right?

sotojuan commented 9 years ago

Yep, thanks for catching that. I'm a bit busy now but later I will clean it up and follow the style guide and submit a PR. Thanks!

rxaviers commented 9 years ago

Excellent. Looking forward to it and thanks.