The pattern }}}}123
is valid syntax in ICU DecimalFormat, because }
is in the legal range for a padding character. This can be validated in PHP as follows:
$f = new NumberFormatter('en_GB', NumberFormatter::PATTERN_DECIMAL, '*}######0');
$this->assertSame('}}}}123', $f->format(123));
-------
correct
But embedding this in ICU MessageFormat, we have the problem that the brace character ends the argument prematurely and would need escaping.
Again, using PHP to verify that this throws IntlException:
$f = new MessageFormatter('en_GB', "{0,number,*}######0}");
$this->assertSame('}}}}123', $f->format([123]));
Quoting the format according to ICU MessageFormat syntax doesn't work either, because a quote symbol is an invalid padChar in the DecimalFormat grammar. In summary, none of these work:
{0,number,*}######0}
{0,number,*'}'######0}
{0,number,'*}######0'}
It seems that the DecimalFormat syntax is not compatible with MessageFormat's argStyleText syntax.
Is this a bug in PHP's Intl extension, or is there a way to escape the decimal pattern in messages?
Please note that this is an academic question about ICU MessageFormat, I am not asking how to pad an integer in PHP.