Commit 92622f12 by David Baumgold

Merge pull request #6373 from edx/improve-i18n-receipt-page

Improve i18n on shoppingcart
parents 20c356bd 08e90d2e
...@@ -1019,8 +1019,13 @@ class PaidCourseRegistration(OrderItem): ...@@ -1019,8 +1019,13 @@ class PaidCourseRegistration(OrderItem):
Generates instructions when the user has purchased a PaidCourseRegistration. Generates instructions when the user has purchased a PaidCourseRegistration.
Basically tells the user to visit the dashboard to see their new classes Basically tells the user to visit the dashboard to see their new classes
""" """
notification = (_('Please visit your <a href="{dashboard_link}">dashboard</a> to see your new course.') notification = _(
.format(dashboard_link=reverse('dashboard'))) u"Please visit your {link_start}dashboard{link_end} "
u"to see your new course."
).format(
link_start=u'<a href="{url}">'.format(url=reverse('dashboard')),
link_end=u'</a>',
)
return self.pk_with_subclass, set([notification]) return self.pk_with_subclass, set([notification])
......
...@@ -241,23 +241,22 @@ def get_processor_decline_html(params): ...@@ -241,23 +241,22 @@ def get_processor_decline_html(params):
# see if we have an override in the microsites # see if we have an override in the microsites
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL) payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
msg = dedent(_( msg = _(
""" "Sorry! Our payment processor did not accept your payment. "
<p class="error_msg"> "The decision they returned was {decision_text}, "
Sorry! Our payment processor did not accept your payment. "and the reason was {reason_text}. "
The decision they returned was <span class="decision">{decision}</span>, "You were not charged. "
and the reason was <span class="reason">{reason_code}:{reason_msg}</span>. "Please try a different form of payment. "
You were not charged. Please try a different form of payment. "Contact us with payment-related questions at {email}."
Contact us with payment-related questions at {email}. )
</p> formatted = msg.format(
""" decision_text='<span class="decision">{}</span>'.format(params['decision']),
)) reason_text='<span class="reason">{code}:{msg}</span>'.format(
code=params['reasonCode'], msg=REASONCODE_MAP[params['reasonCode']],
return msg.format( ),
decision=params['decision'], email=payment_support_email,
reason_code=params['reasonCode'], )
reason_msg=REASONCODE_MAP[params['reasonCode']], return '<p class="error_msg">{}</p>'.format(formatted)
email=payment_support_email)
def get_processor_exception_html(exception): def get_processor_exception_html(exception):
...@@ -266,41 +265,55 @@ def get_processor_exception_html(exception): ...@@ -266,41 +265,55 @@ def get_processor_exception_html(exception):
# see if we have an override in the microsites # see if we have an override in the microsites
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL) payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
if isinstance(exception, CCProcessorDataException): if isinstance(exception, CCProcessorDataException):
msg = dedent(_( msg = _(
""" "Sorry! Our payment processor sent us back a payment confirmation "
<p class="error_msg"> "that had inconsistent data!"
Sorry! Our payment processor sent us back a payment confirmation that had inconsistent data! "We apologize that we cannot verify whether the charge went through "
We apologize that we cannot verify whether the charge went through and take further action on your order. "and take further action on your order."
The specific error message is: <span class="exception_msg">{msg}</span>. "The specific error message is: {error_message}. "
Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}. "Your credit card may possibly have been charged. "
</p> "Contact us with payment-specific questions at {email}."
""".format(msg=exception.message, email=payment_support_email) )
)) formatted = msg.format(
return msg error_message='<span class="exception_msg">{msg}</span>'.format(
msg=exception.message,
),
email=payment_support_email,
)
return '<p class="error_msg">{}</p>'.format(formatted)
elif isinstance(exception, CCProcessorWrongAmountException): elif isinstance(exception, CCProcessorWrongAmountException):
msg = dedent(_( msg = _(
""" "Sorry! Due to an error your purchase was charged for "
<p class="error_msg"> "a different amount than the order total! "
Sorry! Due to an error your purchase was charged for a different amount than the order total! "The specific error message is: {error_message}. "
The specific error message is: <span class="exception_msg">{msg}</span>. "Your credit card has probably been charged. "
Your credit card has probably been charged. Contact us with payment-specific questions at {email}. "Contact us with payment-specific questions at {email}."
</p> )
""".format(msg=exception.message, email=payment_support_email) formatted = msg.format(
)) error_message='<span class="exception_msg">{msg}</span>'.format(
return msg msg=exception.message,
),
email=payment_support_email,
)
return '<p class="error_msg">{}</p>'.format(formatted)
elif isinstance(exception, CCProcessorSignatureException): elif isinstance(exception, CCProcessorSignatureException):
msg = dedent(_( msg = _(
""" "Sorry! Our payment processor sent us back a corrupted message "
<p class="error_msg"> "regarding your charge, so we are unable to validate that "
Sorry! Our payment processor sent us back a corrupted message regarding your charge, so we are "the message actually came from the payment processor. "
unable to validate that the message actually came from the payment processor. "The specific error message is: {error_message}. "
The specific error message is: <span class="exception_msg">{msg}</span>. "We apologize that we cannot verify whether the charge went through "
We apologize that we cannot verify whether the charge went through and take further action on your order. "and take further action on your order. "
Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}. "Your credit card may possibly have been charged. "
</p> "Contact us with payment-specific questions at {email}."
""".format(msg=exception.message, email=payment_support_email) )
)) formatted = msg.format(
return msg error_message='<span class="exception_msg">{msg}</span>'.format(
msg=exception.message,
),
email=payment_support_email,
)
return '<p class="error_msg">{}</p>'.format(formatted)
# fallthrough case, which basically never happens # fallthrough case, which basically never happens
return '<p class="error_msg">EXCEPTION!</p>' return '<p class="error_msg">EXCEPTION!</p>'
......
<%inherit file="shopping_cart_flow.html" /> <%inherit file="shopping_cart_flow.html" />
<%! from django.utils.translation import ugettext as _ %>
<%! from django.core.urlresolvers import reverse %>
<%! <%!
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section, get_course_by_id from courseware.courses import course_image_url, get_course_about_section, get_course_by_id
%> %>
...@@ -20,7 +21,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -20,7 +21,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<div class="message-left"> <div class="message-left">
<% courses_url = reverse('courses') %> <% courses_url = reverse('courses') %>
% if receipt_has_donation_item: % if receipt_has_donation_item:
<b>${_("Thank you for your Purchase!")}</b> <b>${_("Thank you for your purchase!")}</b>
% for inst in instructions: % for inst in instructions:
${inst} ${inst}
% endfor % endfor
...@@ -29,18 +30,33 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -29,18 +30,33 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
## we will show the button View Dashboard ## we will show the button View Dashboard
<% dashboard_url = reverse('dashboard') %> <% dashboard_url = reverse('dashboard') %>
<a href="${dashboard_url}" class="blue pull-right">${_("View Dashboard")} <i class="icon-caret-right"></i></a> <a href="${dashboard_url}" class="blue pull-right">${_("View Dashboard")} <i class="icon-caret-right"></i></a>
<span class="mt-7">${_("You have successfully been enrolled for <b>{appended_course_names}</b>. The following receipt has been emailed to" <span class="mt-7">
" <strong>{appended_recipient_emails}</strong></span>").format(appended_course_names=appended_course_names, appended_recipient_emails=appended_recipient_emails)} ${_(u"You have successfully been enrolled for {course_names}. "
u"The following receipt has been emailed to {receipient_emails}").format(
course_names=u"<b>{course_names}</b>".format(
course_names=appended_course_names
),
receipient_emails=u"<strong>{receipient_emails}</strong>".format(
receipient_emails=appended_recipient_emails
),
)}
</span>
% elif order_type == 'business': % elif order_type == 'business':
% if total_registration_codes > 1 : ${ungettext(
<% code_plural_form = 'codes' %> "You have successfully purchased <b>{number} course registration code</b> for {course_names}.",
% else: "You have successfully purchased <b>{number} course registration codes</b> for {course_names}.",
<% code_plural_form = 'code' %> total_registration_codes
% endif ).format(
${_("You have successfully purchased <b>{total_registration_codes} course registration codes</b> " number=total_registration_codes,
"for <b>{appended_course_names}. </b>" course_names=u"<b>{course_names}</b>".format(
"The following receipt has been emailed to <strong>{appended_recipient_emails}</strong>" course_names=appended_course_names
).format(total_registration_codes=total_registration_codes, appended_course_names=appended_course_names, appended_recipient_emails=appended_recipient_emails)} )
)}
${_("The following receipt has been emailed to {receipient_emails}").format(
receipient_emails=u"<strong>{receipient_emails}</strong>".format(
receipient_emails=appended_recipient_emails,
)
)}
% endif % endif
</div> </div>
...@@ -93,7 +109,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -93,7 +109,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<b>${_('Company Name')}:</b> <b>${_('Company Name')}:</b>
<label> <label>
% if order.company_name: % if order.company_name:
${_("{company_name}").format(company_name=order.company_name)} ${order.company_name}
% else: % else:
N/A N/A
% endif % endif
...@@ -105,7 +121,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -105,7 +121,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<b>${_('Purchase Order Number')}:</b> <b>${_('Purchase Order Number')}:</b>
<label> <label>
% if order.customer_reference_number: % if order.customer_reference_number:
${_("{customer_reference_number}").format(customer_reference_number=order.customer_reference_number)} ${order.customer_reference_number}
% else: % else:
N/A N/A
% endif % endif
...@@ -117,7 +133,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -117,7 +133,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<b>${_('Company Contact Name')}:</b> <b>${_('Company Contact Name')}:</b>
<label> <label>
% if order.company_contact_name: % if order.company_contact_name:
${_("{company_contact_name}").format(company_contact_name=order.company_contact_name)} ${order.company_contact_name}
% else: % else:
N/A N/A
% endif % endif
...@@ -129,7 +145,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -129,7 +145,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<b>${_('Company Contact Email')}:</b> <b>${_('Company Contact Email')}:</b>
<label> <label>
% if order.company_contact_email: % if order.company_contact_email:
${ order.company_contact_email } ${order.company_contact_email}
% else: % else:
N/A N/A
% endif % endif
...@@ -141,7 +157,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c ...@@ -141,7 +157,7 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
<b>${_('Recipient Name')}:</b> <b>${_('Recipient Name')}:</b>
<label> <label>
% if order.recipient_name: % if order.recipient_name:
${_("{recipient_name}").format(recipient_name=order.recipient_name)} ${order.recipient_name}
% else: % else:
N/A N/A
% endif % endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment