[DISCUSSION] ext/intl: single-value skeleton formatter (GH-24165)
| From: | David CARLIER | Date: | Tue, 06 Oct 2026 18:39:59 +0000 |
| Subject: | [DISCUSSION] ext/intl: single-value skeleton formatter (GH-24165) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-132820@lists.php.net to get a copy of this message | ||
Hi,
GH-24165 asks for unit formatting in intl (e.g. "5 km/h", "5 kilometers per
hour"). NumberFormatter can't do it as it sits on the legacy ICU API, and
switching it to icu::number would break patterns, attributes and RBNF
styles.
Since 8.6 it is doable with IntlNumberRangeFormatter by passing the same
value twice, but that's a hack.
I would like to add a single-value counterpart, IntlNumberFormatter, built
from a skeleton:
echo IntlNumberFormatter::createFromSkeleton(
'measure-unit/speed-kilometer-per-hour unit-width-full-name',
'fr')->format(5);
It would cover units and the rest of what skeletons support, and it would
only be available with a recent enough ICU.
Cheers.