In project we are using Freemaker with SpringMVC.
To work with message bundle are used few macros, one of them is
spring.messageArgs
. So today I've spent some time on searching how to pass argument to it. There was only one argument and, obviously, I was expecting that this macros could be used in next way:<@spring.messageArgs "some.message.key" "argumentValue"/>
Unfortunately it's not so easy :(. The macros is calling method that accepts arguments as an array of objects. And string
"argumentValue"
isn't an array. So I found next simple solution:<#assign args = ["Ruslan"]/>
<@spring.messageArgs "hello.man" args/>
where
hello.man = Hello {0}!
Another interesting thing about Freemarker is the way you can print numbers. If you want to print number value in argument X as a regular number rather than formatted number, you may do it in next way ${X?c}. I always forget to add ?c suffix and later receive many errors. Fortunately, it's possible to use #{X} that has the same effect. I found that it saves my time.