Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add contextual markers to checkout templates

Marco Badan7edd71c2fedd
diff --git a/templates/checkout/details.html b/templates/checkout/details.html
index cd336bde98..ce571b8536 100644
--- a/templates/checkout/details.html
+++ b/templates/checkout/details.html
@@ -4,18 +4,20 @@
{% load staticfiles %}
{% load gross net tax from prices_i18n %}
-{% block title %}{% trans "Checkout" %} — {{ block.super }}{% endblock %}
+{% block title %}{% trans "Checkout" context "Checkout page title" %} — {{ block.super }}{% endblock %}
{% block header %}
<div class="container navbar__login">
- <p>{% trans "Easy and secure" %}!</p>
+ <p>{% trans "Easy and secure!" context "Checkout top message" %}</p>
</div>
<header class="checkout__header">
<div class="container">
<a href="/">
- <img src="{% static "images/saleor-logo-black.svg" %}" alt="Testeor - Saleor demo store" height="38">
+ <img src="{% static "images/saleor-logo-black.svg" %}"
+ alt="{% trans "Testeor - Saleor demo store" context "Checkout logo alternate text" %}"
+ height="38">
</a>
- <h1>{% trans "Checkout" %}</h1>
+ <h1>{% trans "Checkout" context "Checkout title" %}</h1>
</div>
</header>
{% endblock %}
@@ -32,41 +34,41 @@
<div class="col-md-5">
{% with total=checkout.get_total %}
<div class="checkout__review">
- <h3 class="checkout__review__tittle">{% trans "Order review" %}</h3>
+ <h3 class="checkout__review__tittle">{% trans "Order review" context "Order review title" %}</h3>
{% for delivery, delivery_cost, total_with_delivery in checkout.deliveries %}
- {% for item, item_price_per_item, item_price_total in delivery %}
- <div class="row">
- <div class="col-8">
- <p><strong>{{ item.variant.product }}</strong> x {{ item.quantity }}<br>
- <span class="checkout__review__variant">{{ item.variant }}</span></p>
- </div>
- <div class="col-4">
- <p class="float-right">{% net item_price_total %}</p>
- </div>
- </div>
- {% endfor %}
+ {% for item, item_price_per_item, item_price_total in delivery %}
+ <div class="row">
+ <div class="col-8">
+ <p><strong>{{ item.variant.product }}</strong> x {{ item.quantity }}<br>
+ <span class="checkout__review__variant">{{ item.variant }}</span></p>
+ </div>
+ <div class="col-4">
+ <p class="float-right">{% net item_price_total %}</p>
+ </div>
+ </div>
+ {% endfor %}
{% endfor %}
<div class="row checkout__review__section">
<div class="col-8">
- <p>{% trans "Delivery" %}</p>
+ <p>{% trans "Delivery" context "Order review section" %}</p>
</div>
<div class="col-4">
<p class="float-right">{% if checkout.shipping_method %}
- {% net checkout.get_total_shipping %}
+ {% net checkout.get_total_shipping %}
{% else %}
- &mdash;
+ &mdash;
{% endif %}</p>
</div>
</div>
<div class="row checkout__review__section">
<div class="col-12">
- <h3>{% trans "Promo code" %}</h3>
- {% include 'checkout/snippets/voucher-form.html' with discount=checkout.discount form=voucher_form %}
+ <h3>{% trans "Promo code" context "Order review section title" %}</h3>
+ {% include "checkout/snippets/voucher-form.html" with discount=checkout.discount form=voucher_form %}
</div>
</div>
<div class="row checkout__review__section">
<div class="col-8">
- <h3>{% trans "Total" %}</h3>
+ <h3>{% trans "Total" context "Order review section title" %}</h3>
</div>
<div class="col-4">
<h3 class="float-right">{% gross total %}</h3>
@@ -75,5 +77,5 @@
</div>
{% endwith %}
</div>
- </div>
+ </div>
{% endblock content %}
diff --git a/templates/checkout/login.html b/templates/checkout/login.html
index ce2e7b75ce..77c63d3299 100644
--- a/templates/checkout/login.html
+++ b/templates/checkout/login.html
@@ -2,22 +2,25 @@
{% load staticfiles %}
{% load i18n %}
-{% block title %}{% trans "Login" %} — {{ block.super }}{% endblock %}
+{% block title %}{% trans "Login" context "Checkout login page title" %} — {{ block.super }}{% endblock %}
{% block content %}
-<div class="row checkout__login">
+ <div class="row checkout__login">
<div class="col-12 col-md-6">
<div class="checkout__login__continue">
- <h3>{% trans "New customer?" %}</h3>
- <img class="checkout-pirate" src="{% static 'images/pirate_login.png' %}" srcset="{% static 'images/pirate-checkout.png' %} 1x, {% static 'images/pirate-checkout2x.png' %} 2x">
- <p><a href="{% url 'checkout:index' %}" class="btn secondary">{% trans "Continue" %}</a></p>
- <p>{% trans "Registration is not required!" %}</p>
+ <h3>{% trans "New customer?" context "Checkout login page title" %}</h3>
+ <img class="checkout-pirate" src="{% static 'images/pirate_login.png' %}"
+ srcset="{% static 'images/pirate-checkout.png' %} 1x, {% static 'images/pirate-checkout2x.png' %} 2x">
+ <p><a href="{% url 'checkout:index' %}" class="btn secondary">
+ {% trans "Continue" context "Checkout login page new users action" %}
+ </a></p>
+ <p>{% trans "Registration is not required!" context "Checkout login page new users message" %}</p>
</div>
</div>
<div class="col-12 col-md-6 checkout__login__form">
{% url "checkout:index" as checkout_url %}
- <h3>{% trans "Existing customer? Log in." %}</h3>
+ <h3>{% trans "Existing customer? Log in." context "Checkout login form title" %}</h3>
{% include "account/partials/login_form.html" with redirect_field_value=checkout_url %}
</div>
-</div>
+ </div>
{% endblock %}
diff --git a/templates/checkout/payment.html b/templates/checkout/payment.html
index 03e1aeb035..0d1802bc03 100644
--- a/templates/checkout/payment.html
+++ b/templates/checkout/payment.html
@@ -6,11 +6,11 @@
{% block forms %}
<form method="post" novalidate>
{% csrf_token %}
- <h1>{% trans "Payment" %}</h1>
+ <h1>{% trans "Payment" context "Checkout payment title" %}</h1>
{% bootstrap_form payment_form %}
{% bootstrap_form billing_address_form %}
<button type="submit" class="btn primary">
- {% trans "Place order" %}
+ {% trans "Place order" context "Checkout payment primary action" %}
</button>
</form>
{% endblock forms %}
diff --git a/templates/checkout/shipping_address.html b/templates/checkout/shipping_address.html
index 087613a536..a6e71570d5 100644
--- a/templates/checkout/shipping_address.html
+++ b/templates/checkout/shipping_address.html
@@ -5,7 +5,7 @@
{% block forms %}
<form method="post" novalidate class="checkout__shipping">
{% csrf_token %}
- <h2>{% trans "Shipping address" %}</h2>
+ <h2>{% trans "Shipping address" context "Checkout shipping address title" %}</h2>
{% if request.user.is_authenticated %}
{% include "checkout/snippets/addresses-form.html" with addresses_form=user_form addresses=additional_addresses address_form=address_form only %}
{% else %}
@@ -15,7 +15,7 @@
<p class="text-md-right">
<button type="submit" class="btn primary">
- {% trans "Continue" %}
+ {% trans "Continue" context "Checkout shipping address primary action" %}
</button>
</p>
</form>
diff --git a/templates/checkout/shipping_method.html b/templates/checkout/shipping_method.html
index 0fd6211cb3..526baf838e 100644
--- a/templates/checkout/shipping_method.html
+++ b/templates/checkout/shipping_method.html
@@ -4,18 +4,20 @@
{% load bootstrap_form from bootstrap3 %}
{% block forms %}
- <h3>{% trans "Shipping address" %}</h3>
+ <h3>{% trans "Shipping address" context "Checkout shipping address title" %}</h3>
{% include "userprofile/snippets/address-short.html" with address=checkout.shipping_address only %}
- <p class="checkout__edit-link"><a href="{% url 'checkout:shipping-address' %}">{% trans "Select other address" %}</a></p>
+ <p class="checkout__edit-link">
+ <a href="{% url 'checkout:shipping-address' %}">{% trans "Select other address" %}</a>
+ </p>
<hr>
<form method="post" class="checkout__shipping-method" novalidate>
{% csrf_token %}
- <h2>{% trans "Shipping method" %}</h2>
+ <h2>{% trans "Shipping method" context "Checkout shipping method form title" %}</h2>
{% bootstrap_form shipping_method_form show_label=False %}
<p class="text-md-right">
- <button type="submit" class="btn primary">
- {% trans "Continue" %}
- </button>
+ <button type="submit" class="btn primary">
+ {% trans "Continue" context "Checkout shipping method primary action" %}
+ </button>
</p>
</form>
{% endblock %}
diff --git a/templates/checkout/snippets/addresses-form.html b/templates/checkout/snippets/addresses-form.html
index 02832fcf25..af0d6999c2 100644
--- a/templates/checkout/snippets/addresses-form.html
+++ b/templates/checkout/snippets/addresses-form.html
@@ -1,11 +1,14 @@
+{% load i18n %}
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
{% if addresses_form.SHIPPING_ADDRESS %}
- {% include "checkout/snippets/addresses-form-panel.html" with parent_element_id="accordion" radio_name=addresses_form.address.html_name radio_value=addresses_form.SHIPPING_ADDRESS label=_('Same as shipping') value=addresses_form.address.value only %}
+ {% trans "Same as shipping" context "Checkout addresses form label" as same_as_shipping %}
+ {% include "checkout/snippets/addresses-form-panel.html" with parent_element_id="accordion" radio_name=addresses_form.address.html_name radio_value=addresses_form.SHIPPING_ADDRESS label=same_as_shipping value=addresses_form.address.value only %}
{% endif %}
{% for address in addresses %}
{% include "checkout/snippets/addresses-form-panel.html" with parent_element_id="accordion" radio_name=addresses_form.address.html_name radio_value=address.id label=address value=addresses_form.address.value address=address only %}
{% endfor %}
{% if addresses_form.NEW_ADDRESS and address_form %}
- {% include "checkout/snippets/addresses-form-panel.html" with parent_element_id="accordion" radio_name=addresses_form.address.html_name radio_value=addresses_form.NEW_ADDRESS label=_('Enter a new address') value=addresses_form.address.value address_form=address_form only %}
+ {% trans "Enter a new address" context "Checkout addresses form label" as enter_a_new_address %}
+ {% include "checkout/snippets/addresses-form-panel.html" with parent_element_id="accordion" radio_name=addresses_form.address.html_name radio_value=addresses_form.NEW_ADDRESS label=enter_a_new_address value=addresses_form.address.value address_form=address_form only %}
{% endif %}
</div>
diff --git a/templates/checkout/snippets/voucher-form.html b/templates/checkout/snippets/voucher-form.html
index de17932f4b..a03d8be84b 100644
--- a/templates/checkout/snippets/voucher-form.html
+++ b/templates/checkout/snippets/voucher-form.html
@@ -11,9 +11,9 @@
{% csrf_token %}
<span>{{ discount.name }}</span>
<button type="submit"
- class="btn btn-link"
- aria-label="{% trans "Remove" %}">
- ({% trans "Remove" %})
+ class="btn btn-link"
+ aria-label="{% trans "Remove" context "Checkout voucher form action" %}">
+ ({% trans "Remove" context "Checkout voucher form action" %})
</button>
</form>
@@ -24,7 +24,10 @@
<form action="{{ request.path }}?next={{ request.path }}"
method="post">
{% csrf_token %}
- <div class="form-group checkout__review__voucher">{% bootstrap_field form.voucher show_label=False %} {% bootstrap_button _("Use") button_type="submit" button_class="btn secondary" %}</div>
+ <div class="form-group checkout__review__voucher">
+ {% trans "Use" context "Checkout voucher form action" as use_voucher %}
+ {% bootstrap_field form.voucher show_label=False %} {% bootstrap_button use_voucher button_type="submit" button_class="btn secondary" %}
+ </div>
</form>
{% endif %}
{% endif %}
diff --git a/templates/checkout/summary.html b/templates/checkout/summary.html
index 1f9fa15b93..1b7c02b308 100644
--- a/templates/checkout/summary.html
+++ b/templates/checkout/summary.html
@@ -2,14 +2,14 @@
{% load i18n %}
{% block forms %}
- <form method="post" novalidate>
- {% csrf_token %}
- <h2>{% trans "Billing address" %}</h2>
- {% include "checkout/snippets/addresses-form.html" with addresses_form=addresses_form addresses=additional_addresses address_form=address_form only %}
- <p class="text-md-right">
- <button type="submit" class="btn primary">
- {% trans "Order &amp Pay" %}
- </button>
- </p>
- </form>
+ <form method="post" novalidate>
+ {% csrf_token %}
+ <h2>{% trans "Billing address" context "Checkout summary title" %}</h2>
+ {% include "checkout/snippets/addresses-form.html" with addresses_form=addresses_form addresses=additional_addresses address_form=address_form only %}
+ <p class="text-md-right">
+ <button type="submit" class="btn primary">
+ {% trans "Order &amp Pay" context "Checkout summary primary action" %}
+ </button>
+ </p>
+ </form>
{% endblock forms %}
diff --git a/templates/checkout/summary_without_shipping.html b/templates/checkout/summary_without_shipping.html
index 022d585fad..e0691e55b9 100644
--- a/templates/checkout/summary_without_shipping.html
+++ b/templates/checkout/summary_without_shipping.html
@@ -5,7 +5,7 @@
{% block forms %}
<form method="post" novalidate>
{% csrf_token %}
- <h2>{% trans "Billing address" %}</h2>
+ <h2>{% trans "Billing address" context "Checkout summary without shipping title" %}</h2>
{% if request.user.is_authenticated %}
{% include "checkout/snippets/addresses-form.html" with addresses_form=addresses_form addresses=additional_addresses address_form=address_form only %}
{% else %}
@@ -14,7 +14,7 @@
{% endif %}
<p class="text-md-right">
<button type="submit" class="btn primary">
- {% trans "Place order" %}
+ {% trans "Place order" context "Checkout summary without shipping action" %}
</button>
</p>
</form>