title: Localization in Spring with Freemarker
body: <p>I am having issues with while working on Localization using Spring+ Freemarker. When I set the browser language as es(Spanish), it works fine. But, when I leave the browser language as default (en-US), it does not load the Spanish text. In fact it loads English texts.</p>
  
  <p>We are controlling localization based on language flag on server side (as of now, may not be the correct way but it's like that for now).</p>
  
  <p>My <strong>FreeMarkerConfigurer</strong> is set up as </p>
  
  <pre><code>@Bean
  public FreeMarkerConfigurer freemarkerConfigurer() throws ParseException {
      FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
      freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/freemarker/");
      freeMarkerConfigurer.setDefaultEncoding("UTF-8");
      Properties properties = new Properties();
      //Hardcoded locale just to test Spanish by default
      properties.put("locale", "es");
      configurer.setFreemarkerSettings(properties);
      Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
      variables.put("utils", new FreemarkerUtils());
      configurer.setFreemarkerVariables(variables);
      return configurer;
  }
  </code></pre>
  
  <p>I have two templates with name <strong>test.ftl</strong> and <strong>test_es.ftl</strong>. So, what I was thinking is it should pick up <strong>test_es.ftl</strong> by default. It picks up if I change the browser preference language to <strong>es</strong> but it does not by default. I also tried setting up <strong>properties.put("localized_lookup", "false");</strong> but did not work.</p>