Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Add selectordinal support and improve locale data #102

Merged
merged 2 commits into from
Mar 9, 2015

Conversation

ericf
Copy link
Collaborator

@ericf ericf commented Mar 6, 2015

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 #84

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
@yahoocla
Copy link

yahoocla commented Mar 6, 2015

CLA is valid!

@ericf
Copy link
Collaborator Author

ericf commented Mar 6, 2015

Note: This PR does not include the dist/ changes since that would make it unmanageable to review.

@caridy
Copy link
Collaborator

caridy commented Mar 6, 2015

🚀

@ericf
Copy link
Collaborator Author

ericf commented Mar 6, 2015

@jasonmit Did you want to review this?

@jasonmit
Copy link
Collaborator

jasonmit commented Mar 7, 2015

LGTM 👍

ericf added a commit that referenced this pull request Mar 9, 2015
Add `selectordinal` support and improve locale data
@ericf ericf merged commit e720669 into formatjs:master Mar 9, 2015
@ericf ericf deleted the selectordinal branch March 9, 2015 02:17
@ericf
Copy link
Collaborator Author

ericf commented Mar 9, 2015

The new plural rule functions generated via make-plural use substr() with negative values which is not supported in IE < 9. We'll need an updated make-plural before publishing these changes to npm.

See: eemeli/make-plural#5

@eemeli
Copy link

eemeli commented Mar 9, 2015

I fixed make-plural to use slice() instead of substr(), which ought to make it work in older IEs, and published this in npm as make-plural@2.1.3.

As a heads-up, I'm working on migrating the make-plural codebase to ES6, and will be eventually publishing that as v2.2 or v3. The idea is to use Babel to transpile it to ES5, and still publish a version using require() in npm.

@ericf
Copy link
Collaborator Author

ericf commented Mar 9, 2015

@eemeli thanks for pushing out the fix! I tested it and everything is working as expected.

Re: ES6 sounds good. We're only using make-plural as a dev dependency, but all of our FormatJS libs are written as ES6 modules transpiled to ES5/3 — although we haven't yet switched to using Babel.

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

Successfully merging this pull request may close these issues.

How about ordinals?
5 participants