i18n email templates

This commit is contained in:
2022-10-21 08:47:58 +03:00
parent 27cb1c0a69
commit efe60cb0c8
3 changed files with 14 additions and 10 deletions

View File

@@ -5,12 +5,14 @@ from settings import MAILGUN_API_KEY, MAILGUN_DOMAIN
api_url = "https://api.mailgun.net/v3/%s/messages" % MAILGUN_DOMAIN
noreply = "discours.io <noreply@%s>" % MAILGUN_DOMAIN
async def send_auth_email(user, token):
async def send_auth_email(user, token, lang="ru"):
try:
to = "%s <%s>" % (user.name, user.email)
# TODO: i18n
subject = "Confirm email"
template = "email_confirmation_ru"
if lang not in ['ru', 'en']:
lang = 'ru'
template = "email_confirmation_" + lang
response = requests.post(
api_url,