<?php
var_dump(msgfmt_format_message('ru_RU', 'The value of {somekey} is {0, choice, 0 #less 12| 12 #between 12 and 32| 32 #more than 32}', ['SomeAnotherKey' => -1]),
msgfmt_format_message('ru_RU', 'The value of {somekey} is {0, choice, 0 #less 12| 12 #between 12 and 32| 32 #more than 32}', [14]),
msgfmt_format_message('ru_RU', 'The value of {somekey} is {0, choice, 0 #less 12| 12 #between 12 and 32| 32 #more than 32}', [133]),
msgfmt_format_message('ru_RU', '{0, plural, =0{Zero}=1{One}other{Unknown #}}', [0]),
msgfmt_format_message('ru_RU', '{0, plural, =0{Zero}=1{One}other{Unknown #}}', [1]),
msgfmt_format_message('ru_RU', '{0, plural, =0{Zero}=1{One}other{Unknown #}}', [2]),
msgfmt_format_message('ru_RU', '{0, select, somevalue{This is some value} other{Unknown value}}', ['somevalue']),
msgfmt_format_message('ru_RU', '{0, select, somevalue{This is some value} other{Unknown value "{0}"}}', ['somevalue2'])
);
var_dump(msgfmt_format_message('en_GB', 'Peter has {0, plural, =0{no cat} =1{a cat} other{# cats}}', [0]),
msgfmt_format_message('en_GB', 'Peter has {0, plural, =0{no cat} =1{a cat} other{# cats}}', [1]),
msgfmt_format_message('en_GB', 'Peter has {0, plural, =0{no cat} =1{a cat} other{# cats}}', [2])
);
?>
输出 (PHP 5.4.17RC1)
==========================
字符串 'The value of -1 is less 12' (长度=26)
字符串 'The value of 14 is between 12 and 32' (长度=36)
字符串 'The value of 133 is more than 32' (长度=32)
字符串 'Zero' (长度=4)
字符串 'One' (长度=3)
字符串 'Unknown 2' (长度=9)
字符串 'This is some value' (长度=18)
字符串 'Unknown value "somevalue2"' (长度=26)
字符串 'Peter has no cat' (长度=16)
字符串 'Peter has a cat' (长度=15)
字符串 'Peter has 2 cats' (长度=16)