package org.gbif.portal.struts.freemarker;

import javax.servlet.ServletContext;

import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GbifFreemarkerManager extends FreemarkerManager {
  private static final Logger LOG = LoggerFactory.getLogger(GbifFreemarkerManager.class);

  @Override
  public void init(ServletContext servletContext) throws TemplateException {
    super.init(servletContext);
    LOG.info("Init custom GBIF Freemarker Manager");
    // custom ftl exception handling
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    // adding date rendering methods
    config.setSharedVariable("niceDate", new NiceDateTemplateMethodModel());
  }

}

@@ -37,16 +37,41 @@
 arker;%0A%0A
+import java.util.Locale;%0A
 import j
@@ -880,15 +880,247 @@
 del());%0A
+    // fixed locale, so we don't get dots as decimal separators or US %22middle endian%22 dates.%0A    // chose UK, as (from the constants available) that gives unambiguous short dates like %2212-Jan-2016%22.%0A    config.setLocale(Locale.UK);%0A
   %7D%0A%0A%7D%0A

Fix FreeMarker locale, so we don't get . as a thousands separator.