mail: format_date plus sympath

This commit is contained in:
Daniel STAN 2014-10-21 23:35:27 +02:00
parent 5c057f83ae
commit 029235cfc4

View file

@ -6,6 +6,7 @@ import jinja2
import sys import sys
import json import json
import inspect import inspect
import locale
from email.header import Header from email.header import Header
from email.message import Message from email.message import Message
@ -28,7 +29,14 @@ text_mutilang_template = template_path + 'text_multilang'
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] ) templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
templateEnv = jinja2.Environment( loader=templateLoader ) templateEnv = jinja2.Environment( loader=templateLoader )
templateEnv.filters['date'] = lambda d: d.strftime('%d %B %Y')
def format_date(d):
if 'fr_FR' in locale.getlocale():
return d.strftime('%A %d %B %Y')
else:
return d.strftime('%A, %B %d %Y')
templateEnv.filters['date'] = format_date
# file extension to rendering function map # file extension to rendering function map