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

Allow translation of invitation emails #869

Open
almet opened this issue Oct 19, 2021 · 12 comments
Open

Allow translation of invitation emails #869

almet opened this issue Oct 19, 2021 · 12 comments

Comments

@almet
Copy link
Member

almet commented Oct 19, 2021

Currently, the invitation emails are directly encoded in templates, and aren't part of the translated strings.

We should change this :-)

@seakyith
Copy link

Hello, I would like to work on this issue. Can you show me which file that I need to work on?

@almet
Copy link
Member Author

almet commented Oct 20, 2021

Hi, thanks for proposing your help.

First, check out the repository locally with git clone, and switch to a branch to make your changes with git checkout -b fix-invitation-emails (or any name you want for the branch, really).

Currently, email sending is done by the render_localized_template function. It checks for the presence of .j2 files in the template folder, and uses them.

Instead, we should probably use one template file, rendered with the render_template function, and let the translation happen directly in the templates.

For this, we should use Jinja2 {% trans %} blocks.

Hope it's clear enough. Let us know if you need some more pointers.

Then, I believe it's possible to change the way the templates are used at the moment.

@seakyith
Copy link

Thank you for your help! I tried to run test based on the documentation with make test command. I ran into the following error

make: *** No rule to make target `test'. Stop.

Any helps would be appreciated.

@almet
Copy link
Member Author

almet commented Nov 6, 2021

@seakyith You need to be in the ihatemoney repository for this makefile command to work. Hope you figured this out :-)

@jsabherwal
Copy link

I could work on it this week if anyone else hasn't. I request you to assign this to me.

@almet
Copy link
Member Author

almet commented Nov 16, 2021

Please go ahead!

@anirudhgad
Copy link

I have been trying to work on this for a while but I am still struggling to understand exactly what must be done, please let me know if a quick chat is possible. Thanks

anirudhgad added a commit to anirudhgad/ihatemoney that referenced this issue Dec 16, 2021
@toodla
Copy link

toodla commented May 18, 2022

hello! do you still need help on this? I am a beginner (like, this would be my first time doing this)! Thank you.

@ayushanand308
Copy link

Hi! I am a first time contributor. Is there anything I can help with?

@afriedman412
Copy link

hey -- I'm working on this and having a little trouble figuring out an Jinja error

I did this ...

  1. Renamed "invitation_mail.en.j2" to "invitation_mail.j2"
  2. Added {% trans %} and {% endtrans %} tags to the beginning and end of "invitation_mail.j2"
  3. Changed line 604 in web.py from ...
    message_body = render_localized_template("invitation_mail")
    to
    message_body = render_template("invitation_mail.j2")

but now all the tests for the invite email (specifically the first two in budget_test.py) are throwing this error:

>   Someone using the email address {{ g.project.contact_email }} invited you to share your expenses for .
E   jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got '.'

ihatemoney/templates/invitation_mail.j2:5: TemplateSyntaxError

any ideas?

@almet
Copy link
Member Author

almet commented Oct 18, 2023

Hi Andy,

This seems related to Jinja not able to read the template. Is it possible that you also changed something else in this template ? You can get the diff with git diff path_to_file to be sure :-)

@afriedman412
Copy link

found a workaround! pull request is up.

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

Successfully merging a pull request may close this issue.

8 participants