-
Notifications
You must be signed in to change notification settings - Fork 77
How about ordinals? #84
Comments
@carystanley that's exactly right. To implement ordinals we need to use CLDR to produce the logic per locale. this is not the first time we get this feature requests, we will evaluate it, but it doesn't belong to this repo for sure since ICU message format does not support ordinals, just like it doesn't support relative time, we can also push for that in that front. |
I did some research and the CLDR has Rule-Based Number Format (RBNF) data, which includes I see a few ways we could implement ordinals: 1) Add support for
|
It looks like Intl.MessageFormat needs a plugin system. |
@juandopazo we don't need a plugin system, we just need to convince ICU folks that @ericf my vote goes to option 2, which will pave the way to option 3, just like we did for |
@caridy @juandopazo I wasn't clear before, but If you look at the details of the ICU Message syntax, you'll see they have support for |
awesome, lets plan for that then, we need an implementer now :) /cc @lwelti |
So we can stage this by first easily adding support for Then we work on the automatic |
By the way, concerning ICU please reach out to us if needed, not so hard to convince, and code does talk :) icu-project.org |
well, they can do that today without anything new:
not ideal, but at least this unblock them. |
@srl295, lets start the conversation about relative time, e.g.: |
@caridy relative time sounds good to me, but probably best started at http://bugs.icu-project.org/trac/newticket . Apologies if you knew this, but the edit on consideration, I think a new ticket would be best, and reference any relevant ones you dig up, or even this thread. This is a great time to suggest changes in msgformat. |
ICU ticket for relative time in messages: http://bugs.icu-project.org/trac/ticket/11409 |
@caridy 👍 . added a backlink here and an xref |
@caridy and, the ICU ticket was moved to unscheduled. Is someone interested in contributing a C++ and Java design and implementation? |
I realized that we do not have that data to support |
@caridy what you wrote in #84 (comment) is not actually correct — |
UpdateI feel we should add basic ordinal support to this project by adding support for
|
This adds support for parsing `selectordinal` arguments, which have similar semantics to `plural` arguments but use ordinal pluralization. Relates to: formatjs/intl-messageformat#84 See: formatjs/intl-messageformat#84 (comment)
This upgrades to intl-messageformat-parser@1.1.0 and adds support for `selectordinal` arguments; e.g.: ``` This is my {year, selectordinal, one {#st} two {#nd} few {#rd} other{#th} } birthday. ``` The locale data has also been vastly improved in the following ways: * Added `pt-PT` plural rule function, which differs from `pt`'s. * Properly de-duplicate data for all CLDR locales by correctly traversing a locale's hierarchy of ancestor locales. * Added data for the following languages: aa, agq, bas, bh, ckb, dav, dje, dsb, dua, dv, dyo, ebu, ewo, guw, guz, hsb, ia, in, iu, iw, jbo, ji, jv, jw, kaj, kam, kcg, khq, ki, kln, kok, ksf, ku, lb, lu, luo, luy, mer, mfe, mgh, mo, mua, nah, nmg, no, nqo, nus, ny, pap, prg, qu, rn, rw, sbp, sh, sma, smi, smj, smn, sms, swc, syr, tk, tl, twq, vai, wa, wo, yav, yi, zgh ---- These changes also include improvements for how locales are resolved. Here are some details of these changes: * If no extra locale data is loaded, the locale will _always_ resolved to `en`. * If locale data is missing for a leaf locale like `fr-FR`, but there _is_ data for the root, `fr` in this case, then its root will be used. * If there's data for the specified locale, then that locale will be resolved; i.e., var mf = new IntlMessageFormat('', 'en-US'); assert(mf.resolvedOptions().locale === 'en-US'); // true * The resolved locales are now normalized; e.g., `en-us` will resolve to: `en-US`. Fixes formatjs#84
PR #102 Implements these |
@ericf sorry to dig up this old issue again but the current
with I'm not sure if you want to track this problem somehow. |
@piuccio I tried numbers going up to 40. All work as expected. 21 generates I'm using latest Here's my code so you can try and see what's different:
|
You're right, I messed up my translation files
…On Wed, 7 Feb 2018, 00:03 Martin Alex Philip Dawson, < ***@***.***> wrote:
@piuccio <https://github.com/piuccio> I tried numbers going up to 40. All
work as expected.
Are you using latest react-intl?
Here's my code so you can try and see different:
export const floorMessages = (positionLowestFloor, positionHighestFloor) => {
const ordinals = 'selectordinal, one {#st} two {#nd} few {#rd} other {#th}';
return defineMessages({
singleFloor: { id: 'Floor.singleFloor', defaultMessage: `{positionLowestFloor, ${ordinals} } floor`, values: { positionLowestFloor } },
multiFloor: { id: 'Floor.multiFloor', defaultMessage: `{positionLowestFloor, ${ordinals}} to {positionHighestFloor, ${ordinals}} floor`, values: { positionLowestFloor, positionHighestFloor } },
});
};
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#84 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAphXAOBXAPp1M6bamLdX6h4F_odBPiVks5tSGmrgaJpZM4DBMRy>
.
|
This adds support for parsing `selectordinal` arguments, which have similar semantics to `plural` arguments but use ordinal pluralization. Relates to: formatjs/intl-messageformat#84 See: formatjs/intl-messageformat#84 (comment)
It would be great if intl-messageformat supported ordinal numbers:
1st, 2nd, 3rd, 4th, 10th, 11th, 12th, 13th, 52nd, 53rd, etc...
Here is a really simple version of the logic:
I am unsure if ordinal works differently in other languages besides english
The text was updated successfully, but these errors were encountered: