php - NumberFormatter::SPELLOUT spellout-ordinal in russian and italian -
php - NumberFormatter::SPELLOUT spellout-ordinal in russian and italian -
this code works english, spanish , high german ordninal numbers, russian or italian ordninal numbers doesn't work.
'ru-ru'
,'it-it'
don't work
i illustration in russian 2 -> два (this cardinal number) , want ordinal number , here 2 -> второй.
i illustration in italian 2 -> due (this cardinal number) , want ordinal number , here 2 -> secondo.
update:
i found solution works in french, spain, high german , other languages:
maskuline ordinal numbers: %spellout-ordinal-maskuline
feminine ordinal numbers: %spellout-ordinal-feminine
russian , italian version doesn't work , tried -maskuline/-feminine
$ru_ordinal = new numberformatter('ru', numberformatter::spellout); $ru_ordinal->settextattribute(numberformatter::default_ruleset, "%spellout-ordinal");
numberformatter using icu formatting.
as can check here: http://saxonica.com/html/documentation/extensibility/config-extend/localizing/icu-numbering-dates/icu-numbering.html
... russian (ru) has next formatting available:
spellout-cardinal-feminine (scf) spellout-cardinal-masculine (scm) spellout-cardinal-neuter (scne) spellout-numbering (sn) spellout-numbering-year (sny)... , 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 why you not able set ordinal format (ru) , next code:
$nformat = new numberformatter('it', numberformatter::spellout); $nformat->settextattribute(numberformatter::default_ruleset, "%spellout-ordinal-feminine"); var_dump($nformat->format(42));
will print:
string 'quarantaduesima' (length=17)
like (propably) want.
edit:
informations used formatting references icu: http://php.net/manual/en/numberformatter.create.php
tested php 5.4.x , icu version => 51.2; icu info version => 51.2. can utilize shell command:
$ php -i | grep icu
to check version of icu have.
for latest icu version should propably install/update php-intl package: http://php.net/manual/en/intl.installation.php
edit 2:
i have created extension numberformatter (so far polish ordinals). sense free contribute languages: https://github.com/arius86/number-formatter
php icu intl numberformatter
Comments
Post a Comment