public function getTemplate($templateId, $language=null)
    {
        if (!$language) {
            $language = $this->getLanguage();
        }
        $select = $this->db->select();
        $select->from('gems__comm_template_translations')
               ->where('gctt_id_template = ?', $templateId)
               ->where('gctt_lang = ?', $language);

        $template = $this->db->fetchRow($select);
        if ($template && !empty($template['gctt_subject'])) {
            return $template;
        }

        if ($language !== $this->project->getLocaleDefault()) {
            $language = $this->project->getLocaleDefault();
            $select = $this->db->select();
            $select->from('gems__comm_template_translations')
                   ->where('gctt_id_template = ?', $templateId)
                   ->where('gctt_lang = ?', $language);

            $template = $this->db->fetchRow($select);
            if ($template && !empty($template['gctt_subject'])) {
                return $template;
            }
        }

        $select = $this->db->select();
        $select->from('gems__comm_template_translations')
               ->where('gctt_id_template = ?', $templateId)
               ->where('gctt_subject <> ""')
               ->where('gctt_body <> ""');
        $template = $this->db->fetchRow($select);
        if ($template && !empty($template['gctt_subject'])) {
            return $template;
        } else {
            return false;
        }
    }