API - use Babel to translate emails

This commit is contained in:
Sam
2022-07-02 19:25:07 +02:00
parent 4abcf050a3
commit fd292a9392
84 changed files with 1302 additions and 686 deletions

View File

@@ -32,7 +32,11 @@ class TestEmailTemplateForAccountConfirmation:
def test_it_gets_subject(
self, app: Flask, lang: str, expected_subject: str
) -> None:
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
email_template = EmailTemplate(
app.config['TEMPLATES_FOLDER'],
app.config['TRANSLATIONS_FOLDER'],
app.config['LANGUAGES'],
)
subject = email_template.get_content(
'account_confirmation', lang, 'subject.txt', {}
@@ -50,7 +54,11 @@ class TestEmailTemplateForAccountConfirmation:
def test_it_gets_text_body(
self, app: Flask, lang: str, expected_text_body: str
) -> None:
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
email_template = EmailTemplate(
app.config['TEMPLATES_FOLDER'],
app.config['TRANSLATIONS_FOLDER'],
app.config['LANGUAGES'],
)
text_body = email_template.get_content(
'account_confirmation', lang, 'body.txt', self.EMAIL_DATA
@@ -59,7 +67,11 @@ class TestEmailTemplateForAccountConfirmation:
assert text_body == expected_text_body
def test_it_gets_en_html_body(self, app: Flask) -> None:
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
email_template = EmailTemplate(
app.config['TEMPLATES_FOLDER'],
app.config['TRANSLATIONS_FOLDER'],
app.config['LANGUAGES'],
)
text_body = email_template.get_content(
'account_confirmation', 'en', 'body.html', self.EMAIL_DATA
@@ -68,7 +80,11 @@ class TestEmailTemplateForAccountConfirmation:
assert expected_en_html_body in text_body
def test_it_gets_fr_html_body(self, app: Flask) -> None:
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
email_template = EmailTemplate(
app.config['TEMPLATES_FOLDER'],
app.config['TRANSLATIONS_FOLDER'],
app.config['LANGUAGES'],
)
text_body = email_template.get_content(
'account_confirmation', 'fr', 'body.html', self.EMAIL_DATA