Skip to content

Commit

Permalink
Merge pull request #25616 from frappe/mergify/bp/version-14-hotfix/pr…
Browse files Browse the repository at this point in the history
…-25614

fix(Contact form): make email content translatable (backport #25614)
  • Loading branch information
barredterra committed Mar 25, 2024
2 parents 446c4d6 + d7864ad commit 2331db4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions frappe/www/contact.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "templates/web.html" %}

{% set title = heading or "Contact Us" %}
{% block header %}<h1>{{ heading or "Contact Us" }}</h1>{% endblock %}
{% block header %}<h1>{{ heading or _("Contact Us") }}</h1>{% endblock %}

{% block page_content %}
<style>
Expand All @@ -23,10 +23,10 @@
<select name="subject" class="form-control">
{% if query_options -%}
{% for option in query_options.split("\n") -%}
<option value="{{ option }}">{{ option }}</option>
<option value="{{ option }}">{{ _(option) }}</option>
{%- endfor %}
{% else %}
<option value="General">General</option>
<option value="General">{{ _("General") }}</option>
{% endif %}
</select>
</div>
Expand Down
15 changes: 12 additions & 3 deletions frappe/www/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,30 @@ def send_message(sender, message, subject="Website Query"):
if forward_to_email := frappe.db.get_single_value("Contact Us Settings", "forward_to_email"):
frappe.sendmail(recipients=forward_to_email, reply_to=sender, content=message, subject=subject)

reply = _(
"""Thank you for reaching out to us. We will get back to you at the earliest.
Your query:
{0}"""
).format(message)
frappe.sendmail(
recipients=sender,
content=f"<div style='white-space: pre-wrap'>Thank you for reaching out to us. We will get back to you at the earliest.\n\n\nYour query:\n\n{message}</div>",
subject="We've received your query!",
content=f"<div style='white-space: pre-wrap'>{reply}</div>",
subject=_("We've received your query!"),
)

# for clearing outgoing email error message
frappe.clear_last_message()

system_language = frappe.db.get_single_value("System Settings", "language")
# add to to-do ?
frappe.get_doc(
dict(
doctype="Communication",
sender=sender,
subject=_("New Message from Website Contact Page"),
subject=_("New Message from Website Contact Page", system_language),
sent_or_received="Received",
content=message,
status="Open",
Expand Down

0 comments on commit 2331db4

Please sign in to comment.