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