def render(self, template_name, context):
languages = self.get_languages(context['receiver'])
template = select_template([
'{}.{}.email'.format(template_name, lang)
for lang in languages
])
# Get the actually chosen language from the template name
language = template.template.name.split('.', 2)[-2]
with translation.override(language):
parts = []
for part_type in ('subject', 'txt', 'html'):
context['part_type'] = part_type
parts.append(template.render(context))
context.pop('part_type')
return tuple(parts)
评论列表
文章目录