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 Invitation Email Translation #1016

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ihatemoney/babel.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_
[jinja2: **/templates/**]
130 changes: 77 additions & 53 deletions ihatemoney/messages.pot
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#, python-format
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""

msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
"accepted."
Expand Down Expand Up @@ -32,10 +36,7 @@ msgid ""
"multiple currencies."
msgstr ""

msgid "Import previously exported JSON file"
msgstr ""

msgid "Import"
msgid "Compatible with Cospend"
msgstr ""

msgid "Project identifier"
Expand Down Expand Up @@ -95,16 +96,16 @@ msgstr ""
msgid "Reset password"
msgstr ""

msgid "Date"
msgid "When?"
msgstr ""

msgid "What?"
msgstr ""

msgid "Payer"
msgid "Who paid?"
msgstr ""

msgid "Amount paid"
msgid "How much?"
msgstr ""

msgid "Currency"
Expand Down Expand Up @@ -160,6 +161,11 @@ msgstr ""
msgid "The email %(email)s is not valid"
msgstr ""

msgid ""
"{error_message} Please check the email configuration of the "
"server{error_extension}"
msgstr ""

#. List with two items only
msgid "{dual_object_0} and {dual_object_1}"
msgstr ""
Expand Down Expand Up @@ -200,28 +206,9 @@ msgstr ""
msgid "This private code is not the right one"
msgstr ""

#, python-format
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""

msgid "A reminder email has just been sent to you"
msgstr ""

msgid ""
"We tried to send you an reminder email, but there was an error. You can "
"still use the project normally."
msgstr ""

#, python-format
msgid "The project identifier is %(project)s"
msgstr ""

msgid ""
"Sorry, there was an error while sending you an email with password reset "
"instructions. Please check the email configuration of the server or "
"contact the administrator."
msgstr ""

msgid "No token provided"
msgstr ""

Expand All @@ -234,17 +221,23 @@ msgstr ""
msgid "Password successfully reset."
msgstr ""

msgid "Project successfully uploaded"
msgid "Unable to parse CSV"
msgstr ""

msgid "Invalid JSON"
msgid "Missing attribute {}"
msgstr ""

msgid ""
"Cannot add bills in multiple currencies to a project without default "
"currency"
msgstr ""

msgid "Project successfully uploaded"
msgstr ""

msgid ": "
msgstr ""

msgid "Project successfully deleted"
msgstr ""

Expand All @@ -258,12 +251,6 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr ""

msgid ""
"Sorry, there was an error while trying to send the invitation emails. "
"Please check the email configuration of the server or contact the "
"administrator."
msgstr ""

#, python-format
msgid "%(member)s has been added"
msgstr ""
Expand Down Expand Up @@ -304,6 +291,9 @@ msgstr ""
msgid "The bill has been modified"
msgstr ""

msgid "{lang} is not a supported language"
msgstr ""

msgid "Error deleting project history"
msgstr ""

Expand Down Expand Up @@ -388,10 +378,7 @@ msgstr ""
msgid "Delete project"
msgstr ""

msgid "Import JSON"
msgstr ""

msgid "Choose file"
msgid "Import project"
msgstr ""

msgid "Download project's data"
Expand Down Expand Up @@ -424,12 +411,21 @@ msgstr ""
msgid "This will remove all bills and participants in this project!"
msgstr ""

msgid "Import previously exported project"
msgstr ""

msgid "Choose file"
msgstr ""

msgid "Edit this bill"
msgstr ""

msgid "Add a bill"
msgstr ""

msgid "Simple operations are allowed, e.g. (18+36.2)/3"
msgstr ""

msgid "Everyone"
msgstr ""

Expand Down Expand Up @@ -542,16 +538,16 @@ msgstr ""
msgid "Delete stored IP addresses"
msgstr ""

msgid "No history to erase"
msgid "No IP Addresses to erase"
msgstr ""

msgid "Clear Project History"
msgid "Delete Stored IP Addresses"
msgstr ""

msgid "No IP Addresses to erase"
msgid "No history to erase"
msgstr ""

msgid "Delete Stored IP Addresses"
msgid "Clear Project History"
msgstr ""

msgid "Time"
Expand Down Expand Up @@ -615,9 +611,15 @@ msgstr ""
msgid "Participant %(name)s: weight changed from %(old_weight)s to %(new_weight)s"
msgstr ""

msgid "Payer"
msgstr ""

msgid "Amount"
msgstr ""

msgid "Date"
msgstr ""

#, python-format
msgid "Amount in %(currency)s"
msgstr ""
Expand Down Expand Up @@ -691,6 +693,37 @@ msgid ""
"your friends"
msgstr ""

msgid "Hi"
msgstr ""

#, python-format
msgid ""
"Someone using the email address %(contact_email)sinvited you to share "
"your expenses for \"%(name)s\"."
msgstr ""

msgid ""
"It's as simple as saying what did you pay for, for whom, and how much did"
" it cost you, we are caring about the rest."
msgstr ""

#, python-format
msgid "You can log in using this link: %(link)s."
msgstr ""

#, python-format
msgid ""
"Once logged-in, you can use the following link which is easier to "
"remember: %(short_link)s If your cookie gets deleted or if you log out, "
"you will need to log back in using the first link."
msgstr ""

msgid "Enjoy"
msgstr ""

msgid "See you :-)"
msgstr ""

msgid "Account manager"
msgstr ""

Expand Down Expand Up @@ -761,30 +794,21 @@ msgstr ""
msgid "Invite people"
msgstr ""

msgid "You should start by adding participants"
msgstr ""

msgid "Add a new bill"
msgstr ""

msgid "Newer bills"
msgstr ""

msgid "Older bills"
msgstr ""

msgid "When?"
msgid "You should start by adding participants"
msgstr ""

msgid "Who paid?"
msgid "Add a new bill"
msgstr ""

msgid "For what?"
msgstr ""

msgid "How much?"
msgstr ""

#, python-format
msgid "Added on %(date)s"
msgstr ""
Expand Down
16 changes: 16 additions & 0 deletions ihatemoney/templates/invitation_mail.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% trans %}Hi{% endtrans %},
{% trans trimmed contact_email=g.project.contact_email, name=g.project.name %}
Someone using the email address {{ contact_email }}invited you to share your expenses for "{{ name }}".
{% endtrans %}
{% trans trimmed %}
It's as simple as saying what did you pay for, for whom, and how much did it cost you, we are caring about the rest.
{% endtrans %}
{% trans trimmed link=url_for(".join_project", _external=True, project_id=g.project.id, token=g.project.generate_token()) %}
You can log in using this link: {{ link }}.
{% endtrans %}
{% trans trimmed short_link=url_for(".list_bills", _external=True) %}
Once logged-in, you can use the following link which is easier to remember: {{ short_link }}
If your cookie gets deleted or if you log out, you will need to log back in using the first link.
{% endtrans %}
{% trans %}Enjoy{% endtrans %},
{% trans %}See you :-){% endtrans %}
41 changes: 41 additions & 0 deletions ihatemoney/tests/budget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,47 @@ def test_invite(self):
resp = self.client.get("/raclette/join/token.invalid", follow_redirects=True)
self.assertIn("Provided token is invalid", resp.data.decode("utf-8"))

def test_translated_invite(self):
"""Test that invitation e-mails are translated properly"""
self.login("raclette")
self.post_project("raclette")
# Set default locale to France to trigger translation
self.app.config["BABEL_DEFAULT_LOCALE"] = "fr"
with self.app.mail.record_messages() as outbox:
self.client.post("/raclette/invite", data={"emails": "[email protected]"})
self.assertEqual(len(outbox), 1)
url_start = (
outbox[0].body.find("Vous pouvez vous connecter grâce à ce lien :") + 45
)
url_end = outbox[0].body.find(".\n", url_start)
url = outbox[0].body[url_start:url_end]
self.client.get("/exit")
# Test that we got a valid token
resp = self.client.get(url, follow_redirects=True)
self.assertIn(
'Vous souhaitez sûrement <a href="/raclette/members/add"',
resp.data.decode("utf-8"),
)
# Test empty and invalid tokens
self.client.get("/exit")
# Use another project_id
parsed_url = urlparse(url)
resp = self.client.get(
urlunparse(
parsed_url._replace(
path=parsed_url.path.replace("raclette/", "invalid_project/")
)
),
follow_redirects=True,
)
assert "Créer un nouveau projet" in resp.data.decode("utf-8")

# A token MUST have a point between payload and signature
resp = self.client.get(
"/raclette/join/token.invalid", follow_redirects=True
)
self.assertIn("Ce jeton est invalide", resp.data.decode("utf-8"))

def test_invite_code_invalidation(self):
"""Test that invitation link expire after code change"""
self.login("raclette")
Expand Down
Binary file modified ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo
Binary file not shown.
Loading