NumberFormatter::SPELLOUT spellout-ordinal in russian and italian

只谈情不闲聊 提交于 2019-12-04 19:25:35


this code works for english, spanish and german ordninal numbers, but with russian or italian ordninal numbers it doesn't work.

'ru-RU','it-IT' also don't work

I get for example in russian for 2 -> два (this is the cardinal number) , but I want the ordinal number and this would be here 2 -> второй.

I get for example in italian for 2 -> due (this is the cardinal number) , but I want the ordinal number and this would be here 2 -> secondo.


I found a solution with works in french, spain, german and some other languages:

maskuline ordinal numbers: %spellout-ordinal-maskuline

feminine ordinal numbers: %spellout-ordinal-feminine

russian and italian version doesn't work and I tried already with -maskuline/-feminine

$ru_ordinal = new NumberFormatter('ru', NumberFormatter::SPELLOUT);
$ru_ordinal->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-ordinal");  


NumberFormatter is using ICU formatting.

As you can check here:

... Russian (ru) has following formatting available:

  • spellout-cardinal-feminine (scf)
  • spellout-cardinal-masculine (scm)
  • spellout-cardinal-neuter (scne)
  • spellout-numbering (sn)
  • spellout-numbering-year (sny)

... and Italian (it):

  • spellout-cardinal-feminine (scf)
  • spellout-cardinal-masculine (scm)
  • spellout-numbering (sn)
  • spellout-numbering-year (sny)
  • spellout-ordinal-feminine (sof)
  • spellout-ordinal-masculine (som)

That is why you will not be able to set ordinal format for (ru) and following code:

$nFormat = new NumberFormatter('it', NumberFormatter::SPELLOUT);
$nFormat->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-ordinal-feminine");


Will print:

string 'quaranta­duesima' (length=17)

Like you (propably) want.


Informations about used formatting with references to ICU:

Tested with PHP 5.4.x and ICU version => 51.2; ICU Data version => 51.2. You can use shell command:

$ php -i | grep ICU

To check what version of ICU you have.

For latest ICU version you should propably install/update php-intl package:


I have created extension for NumberFormatter (so far with polish ordinals). Feel free to contribute another languages:


Just a Recommendation, I am not sure if this works or have an Apache services open at this point of time as I am at college, but have you tried to put ru-RU for Russia. In PHP I personally put my Language Codes as "en-GB"

Here is a List I found on the internet with some to help you.