views:

105

answers:

1

Hi,

for ($rank=0; $rank<100; $rank++)
{
  printf("Your rank: %d%s", $rank, $suffix);
}

Is there exist a gettext function to localize $suffix in the general case (any language)?

Thank you.

+3  A: 

Not that I know of, but you can use NumberFormatter

$nf = new NumberFormatter('en_US', NumberFormatter::ORDINAL);
print $nf->format(123); // prints 123rd

Source:

Gordon
I don't know if I've discovered a bug in PHP or the Swedish language pack, but doing this for sv_SE or sv_FI for 1 returns "1:e%digits-ordinal-neutre:0: 1:a" Or am I missing an additional argument?
Lucent