I would like to use named arguments in a string passed to MessageFormater, like that
$fmt = new MessageFormatter("en_US", "My name id {my_name}");
$fmt->format(array('my_name' => 'John'));
When I running this code, I obtain the error message :
$fmt->getErrorMessage() returns
Number formatting failed: U_ILLEGAL_ARGUMENT_ERROR
Whereas
$fmt = new MessageFormatter("en_US", "My name id {0}");
$fmt->format(array(0 => 'John'));
works well.
icu-project website report that named arguments are supported since ICU 3.8 (Seen here), and I use the 4.2.1
Where is the unicorn? PHP doesn't support named arguments for MessageFormatter? Maybe there is an alternative?