title: How can I reduce the duplication in the Clojure code below?
body: <p>I have the following Clojure code with a <strong>render</strong> function which renders a html page using enlive-html. Depending on the selected language a different html template is used.</p>
  
  <p>As you can see, there is a lot of code duplication and I would like to remove it. </p>
  
  <p>I was thinking of writing some macros but, if I understand correctly, the language (i.e. lang parameter) is not available at macro execution time because it is provided in the request and that is at execution time and not at compilation time.  </p>
  
  <p>I also tried to modify enlive in order to add i18n support at some later point but my Clojure skills are not there yet.</p>
  
  <p>So the questions are: </p>
  
  <p>How can I remove the code duplication in the code below?</p>
  
  <p>Is enlive-html the way to go or should I use another library?
  Is there a library similar to enlive with support for i18n?</p>
  
  <p>Thanks!</p>
  
  <p>See the code here:</p>
  
  <pre><code>(ns myapp.core
    (:require [net.cgrand.enlive-html :as e))
  
  (deftemplate not-found-en "en/404.html"
    [{path :path}]
    [:#path] (e/content path))
  
  (deftemplate not-found-fr "fr/404.html"
    [{path :path}]
    [:#path] (e/content path))
  
  
  (defn getTemplate [page lang]
    (case lang
        :en (case page
                  :page/not-found not-found-en)
        :fr (case page
                  :page/not-found not-found-fr)))
  
  (defn render [lang [page params]]
    (apply (getTemplate page lang) params))
  </code></pre>