phpinternationalizationicupluralcldr

In ICU, is it possible to use custom plural rules instead of CLDR rules


So I want to use a different plural rule than what is in the CLDR. I'm using ICU through PHP intl extension, and say I have something like this:

$msg = new MessageFormatter('ar',
                '{0,plural,  zero {zero-ar}' .
                'one {one-ar}' .
                'two {two-ar}' .
                'few {{0,number} few-ar}' .
                'many {{0,number} many-ar}' .
                'other{{0,number} other-ar} }.');

I'm not happy with the built in plural rule for one of the categories and would like to change it, is that possible? And no it's not just fixed intervals, so can't use choices.


Solution

  • I think you would need to create a PluralRules object using PluralRules.createRules() and then create your own PluralFormat using those rules and a pattern.