Skip to content
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: Translation preparation for fundraising app #1687

Merged
merged 7 commits into from
Nov 1, 2024

Conversation

marksweb
Copy link
Contributor

This adds translations tags to the fundraising app as suggested in #1648

@marksweb marksweb marked this pull request as draft October 23, 2024 19:28
@marksweb marksweb marked this pull request as ready for review October 23, 2024 20:45
Copy link
Member

@bmispelon bmispelon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plaintext files need to be handled a bit differently since spaces and newlines there are significant (unlike in HTML).

Localization is hard work, isn't it? 😁

DSF via payroll deduction.</li>
<li>
{% blocktranslate trimmed %}
<a href="https://django.threadless.com/" target="_blank">Official merchandise store</a> -
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, but I wonder if this is a problem with a known solution:

with the current translation infrastructure, translators have the power to do some significant (and potentially malicious) modifications to the HTML like changing the href or even injecting a <script> tag.
Are there tools that can help with that, or is that something that needs to be verified by hand for each language/string?

djangoproject/templates/fundraising/manage-donations.html Outdated Show resolved Hide resolved
fundraising/forms.py Show resolved Hide resolved
fundraising/forms.py Show resolved Hide resolved
djangoproject/templates/fundraising/email/thank-you.html Outdated Show resolved Hide resolved
@marksweb
Copy link
Contributor Author

@bmispelon Ok, I think I've addressed all the issues here - thanks for another review!

Copy link
Member

@bmispelon bmispelon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still an issue with plaintext templates: the { %blocktranslate %} are inserting extra new lines.

Here's the code I used to test this:

from django.template import loader
print(loader.get_template("fundraising/email/payment_failed.txt").render({"donation":{"donor": {"pk": 1234, "name_with_fallback": "TEST"}}}))

If you run this code on main vs. marksweb:feat/i18n-fundraising/1648 you'll see extra blank lines between paragraphs. Ideally, the output should be identical.

@marksweb
Copy link
Contributor Author

@bmispelon Ah yes, apologies - didn't realise that blocktranslate created space like this. 🤦🏼

I've corrected the 3 email templates - though we are adding a blank line at the end of files so there is that still.

>>> from django.template import loader
>>> print(loader.get_template("fundraising/email/payment_failed.txt").render({"donation":{"donor": {"pk": 1234, "name_with_fallback": "TEST"}}}))
Hi TEST,

This is to let you know that payment for your recurring donation to the Django Software Foundation has failed.
This might be because your payment card has expired.

Please go to http://www.djangoproject.localhost:8000/fundraising/manage-donations/1234/ to add a new card. We won't be able to take any payments in the mean time.

Thanks very much for your support.

Regards,
Django Software Foundation

>>> print(loader.get_template("fundraising/email/subscription_cancelled.txt").render({"donation":{"donor": {"pk": 1234, "name_with_fallback": "TEST"}}}))
Hi TEST,

This is to let you know that your recurring payment to the Django Software
Foundation has been cancelled. No further payments will be made.

If you didn't intend to do this, please go back to the fundraising page and
recreate your payment subscription:
http://www.djangoproject.localhost:8000/fundraising/
Thanks very much for your support.

Regards,
Django Software Foundation

>>> print(loader.get_template("fundraising/email/thank-you.html").render({"donation":{"donor": {"pk": 1234,}}}))
Hello!

Thank you for making a donation to the Django Software Foundation.

Your support is invaluable to continue the rapid development of Django and helps the Django Fellowship program in particular.

If you want to change information about your donation, you can do so by accessing the link below:

http://www.djangoproject.localhost:8000/fundraising/manage-donations/1234/

Best regards,
Django Software Foundation

@@ -1,10 +1,15 @@
Hi {{ donation.donor.name_with_fallback }},
{% load i18n %}{% spaceless %}{% url 'fundraising:manage-donations' donation.donor.pk as manage_url %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever use of spaceless 👍🏻

@bmispelon bmispelon merged commit a41119e into django:main Nov 1, 2024
5 checks passed
Copy link

sentry-io bot commented Nov 5, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: 'bool' object is not callable fundraising.views.receive_webhook View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants