Skip to content

Collect all possible MessageFormat use cases #119

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

Closed
romulocintra opened this issue Sep 28, 2020 · 6 comments
Closed

Collect all possible MessageFormat use cases #119

romulocintra opened this issue Sep 28, 2020 · 6 comments
Labels
requirements Issues related with MF requirements list

Comments

@romulocintra
Copy link
Collaborator

romulocintra commented Sep 28, 2020

The goal is to collect real/possible examples for message format. That way we can create a dataset of formats and use cases that will allow us to evaluate and understand the real needs of the users.

  • "Cases that are extreme or hard to implement are the ones we wan't to see :) "
  • "Bad i18n practices"

Please add below all the use cases you can find

** This issue is duplication of #2 **

@nbouvrette
Copy link
Collaborator

I dare anyone to translate this example to Arabic, using external selectors only:

This all-inclusive resort includes {poolCount, plural, =0 {no pools} one {# pool} other {# pools}}, {restaurantCount, plural, =0 {no restaurants} one {# restaurant} other {# restaurants}}, {beachCount, plural, =0 {no beaches} one {# beach} other {# beaches}} and {golfCount, plural, =0 {no golf courses} one {# golf course} other {# golf courses}}.

@eemeli
Copy link
Collaborator

eemeli commented Sep 30, 2020

I posted my degenerate-case message example in this comment on #103.

@stasm
Copy link
Collaborator

stasm commented Oct 19, 2020

Here's an example from Mozilla's Common Voice website, in Fluent syntax. The message uses from independent plurals:

activity-needed-calculation-plural = { NUMBER($totalHours) -> 
    [one] {$totalHours} hour
   *[other] {$totalHours} hours
} is achievable in just over { NUMBER($periodMonths) -> 
    [one] {$periodMonths} month
   *[other] {$periodMonths} months
} if { NUMBER($people) -> 
    [one] {$people} person
   *[other] {$people} people
} record { NUMBER($clipsPerDay) -> 
    [one] {$clipsPerDay} clip 
   *[other] {$clipsPerDay} clips 
} a day.

@mihnita
Copy link
Collaborator

mihnita commented Oct 19, 2020

@comment 2

mainMessage = This all-inclusive resort includes {listOfFeatures}.
featurePools = {poolCount, plural, =0 {no pools} one {# pool} other {# pools}}
featureRestaurants = {restaurantCount, plural, =0 {no restaurants} one {# restaurant} other {# restaurants}}
featureBeaches = {beachCount, plural, =0 {no beaches} one {# beach} other {# beaches}}
featureGolf = {golfCount, plural, =0 {no golf courses} one {# golf course} other {# golf courses}}
...
// And use a ListFormatter

This allows even nicer final result by allowing the exclusion of the =0 cases, because (maybe) we don't want to say
"This all-inclusive resort includes no pools, 1 restaurant, no beaches, and no golf course."

You only add to the list the features that have a count > 0.

@mihnita
Copy link
Collaborator

mihnita commented Oct 19, 2020

So the final result would be something like this (the "all plural" case)

70 hours is achievable in just over 2 months if 2 people record 3 clips a day.

This is how I would "attack" it:

{ [plural(peopleCount), plural (clipCount)]
  [  one   one] {hoursDuration} is achievable in just over {monthsDuration} if {$people} person {$clipsPerDay} clip a day.}
  [other   one] {hoursDuration} is achievable in just over {monthsDuration} if {$people} people {$clipsPerDay} clip a day.}
  [  one other] {hoursDuration} is achievable in just over {monthsDuration} if {$people} person {$clipsPerDay} clips a day.}
  [other other] {hoursDuration} is achievable in just over {monthsDuration} if {$people} people {$clipsPerDay} clips a day.}
}

We have duration formatters in ICU.
If a platform does not have them, the MF2 will accept custom functions (we all agree?), and one can add them.

"Support custom / pluggable "formatters" (beside Date/Time/Number ...)" #22

"Have pluggable “formatters”(Date/Time/Number ...)" #3

"IMHO the future MF API should be focused on providing a low-level set of APIs extending the built-in Intl with reusable and pluggable formatters etc..." #2

@aphillips
Copy link
Member

This issue appears to be duplicated by other issues and is not being used to track all use cases. The discussion of examples above is a good one, but is now stale. If you are considering reopening this issue, please think about opening a new issue or issues with specific change requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requirements Issues related with MF requirements list
Projects
None yet
Development

No branches or pull requests

6 participants