Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

messageSource doesn't replace all arguments in template

I have code:

messageSource.getMessage("some.key",new Object[]{30,31},Constants.LOCALE)

and key inside property file:

some.key=Csv header length ({0}) doesn't correspond the mapping file size {1} .

but result is strange:

Csv header length (30) doesn't correspond the mapping file size {1} .

Fisrt variable was successfully replaced but second - not.

Why does second argument was not resolved?

like image 394
gstackoverflow Avatar asked Dec 19 '22 02:12

gstackoverflow


1 Answers

The problem is because you have a single quote in the message that you have not escaped.

See https://www.mscharhag.com/java/resource-bundle-single-quote-escaping for an example of your problem.

like image 138
adamcooney Avatar answered Dec 28 '22 06:12

adamcooney