-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Email made translatable #7416
Conversation
Codecov Report
@@ Coverage Diff @@
## development #7416 +/- ##
===============================================
+ Coverage 65.28% 65.29% +0.01%
===============================================
Files 265 265
Lines 13205 13212 +7
===============================================
+ Hits 8621 8627 +6
- Misses 4584 4585 +1
Continue to review full report at Codecov.
|
app/api/auth.py
Outdated
send_email( | ||
to=user, | ||
action=PASSWORD_RESET_AND_VERIFY, | ||
html=render_template('email/password_reset_and_verify', **context), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass context as keyword arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.html missing
app/api/auth.py
Outdated
send_email( | ||
to=user, | ||
action=PASSWORD_RESET, | ||
html=render_template('email/password_reset', **context), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass context as keyword arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.html missing
app/api/users.py
Outdated
to=user, | ||
action=USER_REGISTER, | ||
subject=MAILS[USER_REGISTER]['subject'].format(app_name=settings['app_name']), | ||
html=render_template('email/user_register.html', **context), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass context as keyword arguments
app/api/auth.py
Outdated
subject=MAILS[PASSWORD_CHANGE]['subject'].format( | ||
app_name=get_settings()['app_name'] | ||
), | ||
html=render_template('email/password_change'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.html missing
@@ -0,0 +1,3 @@ | |||
Please use the following link to reset your password. | |||
<br/><a href='{link}' target='_blank'>{{ link }}</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<br/><a href='{link}' target='_blank'>{{ link }}</a> | |
<br/>{{ link }} |
@@ -0,0 +1,2 @@ | |||
Please use the following link to reset your password and verify your account. | |||
<br> <a href='{link}' target='_blank'> {{ link }} </a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<br> <a href='{link}' target='_blank'> {{ link }} </a> | |
<br>{{ link }} |
93eb0e6
to
b27beca
Compare
@iamareebjamal - mo file created. |
{{ _('Hello') }}, | ||
<br/><br/>{{ _('Thank you for your ticket order for') }} {{ order.event.name }}. | ||
<br/><br/>{{ _('This is your order confirmation. You can download your tickets at') }} : {{ order_view_url }} | ||
<br/><br/>{{ _('Order Summary') }}: | ||
<br/>Order: {{ order.invoice_number }} | ||
<br/>Name: {{ order.user.full_name }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_() missing here
<br/><br/>Ticket Summary: | ||
{{ _('Hello') }}, | ||
<br/><br/>{{ _('This is a confirmation mail of your tickets for the event') }} {{ order.event.name }}. {{ _('You can download your tickets at') }}: {{ order_view_url }} | ||
<br/><br/>{{ _('Ticket Summary') }}: | ||
<br/>Name: {{ attendees.0.user.full_name }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_() missing here
@@ -0,0 +1,7 @@ | |||
{{ _('Hello') }}, | |||
<br/><br/>{{ _('Your account has been created on') }} {{ settings.app_name }}. {{ _('Congratulations! ') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<br/><br/>{{ _('Your account has been created on') }} {{ settings.app_name }}. {{ _('Congratulations! ') }} | |
<br/><br/>{{ _('Your account has been created on') }} {{ settings.app_name }}. {{ _('Congratulations!') }} |
@@ -0,0 +1,7 @@ | |||
{{ _('Hello') }}, | |||
<br/><br/>{{ _('Your account has been created on') }} {{ settings.app_name }}. {{ _('Congratulations! ') }} | |||
<br/><br/>{{ _('Your login is: {{ email }} ')}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
email should be out of _()
<br/><br/>{{ _('Your login is: {{ email }} ')}} | ||
<br/><br/>{{ _('Please visit the following link to verify your email:') }} {{ link }} | ||
<br/><br/>{{ _('Thank You') }}, | ||
<br/><br/>{{ settings.app_name }} Team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_() missing here
@iamareebjamal - While passing context as keyword argument in send_email function , the jinja html template doesn't recognize values and give error object not found. What should be done? |
2e094bf
to
4180fec
Compare
You don't pass context as kwarg, you pass contents of context as kwargs |
app/api/users.py
Outdated
action=USER_REGISTER, | ||
subject=MAILS[USER_REGISTER]['subject'].format(app_name=settings['app_name']), | ||
html=render_template('email/user_register.html', context=context), | ||
attachments=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If attachments is None, then this is not needed
config.py
Outdated
@@ -49,6 +49,7 @@ class Config: | |||
FLASK_ADMIN_SWATCH = 'lumen' | |||
|
|||
VERSION = VERSION_NAME | |||
LANGUAGES = ['en', 'de', 'fr'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add all languages present in the translations folder
messages.pot
Outdated
@@ -0,0 +1,125 @@ | |||
# Translations template for PROJECT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add required dependencies in requirements
4180fec
to
f1727ee
Compare
@iamareebjamal - Done the changes, performed the testing |
requirements/common.txt
Outdated
@@ -62,6 +62,7 @@ pyyaml==5.3.1 | |||
sendgrid==6.4.7 | |||
marshmallow==2.15.2 | |||
WeasyPrint==52.1 | |||
Flask-Babel=2.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong syntax
Please add a screenshot of the mail you received and fix the build |
cbea6c2
to
9d5e642
Compare
Disable https://google.github.io/pytype/errors.html#mro-error on |
Please also write the command to extract to pot, merge to po, and generating mo files because I'll need that for testing |
Extracting to pot Updating po Generating mo |
d166be8
to
78c06ad
Compare
@iamareebjamal - Done! |
How did you test the translation was happening? |
As you sugggested, In the i changed my browser display language in firefox to German (De), the website was translated to german now. |
OK. Thank you |
<br/>Quantity: {{ attendee | length }} | ||
{% for i, attendee in attendees | groupby('ticket_id') %} | ||
<br/>{{ _('Ticket') }}: {{ attendee.0.ticket.name }} | ||
<br/>{ _('Quantity') }}: {{ attendee | length }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ missing
78c06ad
to
d4ce99b
Compare
Fixes #7405
Short description of what this resolves:
Changes proposed in this pull request:
Checklist
development
branch.