HI,
I have a typical messages.properties file in my application.
I'm trying to generate an email using Freemarker.
The Freemarker template should generate to a String, after which I'll send the String to the user via email. However, we need it multilingual.
So Properties came to mind.
My properties file looks like this:
mail.layout.contactus=Contacteer ons
mail.layout.greeting=Hoi
In Java, I enter the Properties file in my HashMap like this:
rootMap.put("lang", (mail.getLanguage().equals(Language.FRENCH) ? langFR : langNL));
And try to read it in FreeMarker like this:
<p>${lang.mail.layout.greeting} ${user.firstname},</p>
But get following exception:
freemarker.core.InvalidReferenceException: Expression lang.mail is undefined on line 10, column 116 in layout/email.ftl.
Strangely, it only says lang.mail as opposed to lang.mail.layout.greeting
Edit: I tried defining my keys like this:
mail_layout_contactus=Contacteer ons
mail_layout_greeting=Hoi
which does work