[FIX] website_sale_aplicoop: translate cart labels safely

This commit is contained in:
snt 2026-03-31 16:18:40 +02:00
parent 603e6b6aa1
commit c17bd7eddd
4 changed files with 17 additions and 16 deletions

View file

@ -367,7 +367,8 @@ class AplicoopWebsiteSale(WebsiteSale):
product_price_info: dict with price data keyed by product.id.
Returns:
dict with display_price, safe_uom_category, quantity_step, price_unit_suffix
dict with display_price, safe_uom_category, quantity_step,
price_unit_suffix and translated accessibility labels.
"""
price_data = product_price_info.get(product.id, {})
price = (
@ -414,11 +415,18 @@ class AplicoopWebsiteSale(WebsiteSale):
str(e),
)
out_of_stock_label = request.env._("Out of stock")
add_to_cart_label = request.env._(
"Add %(product_name)s to cart", product_name=product.name
)
return {
"display_price": price_safe,
"safe_uom_category": uom_category_name,
"quantity_step": quantity_step,
"price_unit_suffix": price_unit_suffix,
"out_of_stock_label": out_of_stock_label,
"add_to_cart_label": add_to_cart_label,
}
def _get_pricing_info(self, product, pricelist, quantity=1.0, partner=None):

View file

@ -257,6 +257,7 @@ msgstr "Añadir {{ product.name }} al carrito"
#. module: website_sale_aplicoop
#. odoo-python
#: code:addons/website_sale_aplicoop/controllers/website_sale.py:0
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
msgid "Add %(product_name)s to cart"
msgstr "Añadir %(product_name)s al carrito"
@ -2171,6 +2172,8 @@ msgid "Order is not available"
msgstr "El pedido no está disponible"
#. module: website_sale_aplicoop
#. odoo-python
#: code:addons/website_sale_aplicoop/controllers/website_sale.py:0
msgid "Out of stock"
msgstr "Sin existencias"
@ -2313,10 +2316,3 @@ msgstr "Semanal"
msgid "Whether this picking includes home delivery (from sale order)"
msgstr "Si este albarán incluye entrega a domicilio (del pedido de venta)"
#. module: website_sale_aplicoop
msgid ""
"{{ 'Out of stock' if product.is_out_of_stock else 'Add %s to cart' % "
"product.name }}"
msgstr ""
"{{ 'Sin existencias' if product.is_out_of_stock else 'Añadir %s al carrito' "
"% product.name }}"

View file

@ -258,6 +258,7 @@ msgstr "{{ product.name }} sarrera gehitu"
#. module: website_sale_aplicoop
#. odoo-python
#: code:addons/website_sale_aplicoop/controllers/website_sale.py:0
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
msgid "Add %(product_name)s to cart"
msgstr "%(product_name)s saskira gehitu"
@ -2178,6 +2179,8 @@ msgid "Order is not available"
msgstr "Eskaera ez dago erabilgarri"
#. module: website_sale_aplicoop
#. odoo-python
#: code:addons/website_sale_aplicoop/controllers/website_sale.py:0
msgid "Out of stock"
msgstr "Stockik ez"
@ -2307,9 +2310,3 @@ msgstr ""
"eskaeraren)"
#. module: website_sale_aplicoop
msgid ""
"{{ 'Out of stock' if product.is_out_of_stock else 'Add %s to cart' % "
"product.name }}"
msgstr ""
"{{ 'Stockik ez' if product.is_out_of_stock else '%s saskian gehitu' % "
"product.name }}"

View file

@ -636,8 +636,8 @@
<t t-set="safe_uom_category" t-value="product_display_info.get(product.id, {}).get('safe_uom_category', '')" />
<t t-set="quantity_step" t-value="product_display_info.get(product.id, {}).get('quantity_step', 1)" />
<t t-set="order_id_safe" t-value="group_order.id if group_order else ''" />
<t t-set="out_of_stock_label" t-value="_('Out of stock')" />
<t t-set="add_to_cart_label" t-value="_('Add %(product_name)s to cart') % {'product_name': product.name}" />
<t t-set="out_of_stock_label" t-value="product_display_info.get(product.id, {}).get('out_of_stock_label', 'Out of stock')" />
<t t-set="add_to_cart_label" t-value="product_display_info.get(product.id, {}).get('add_to_cart_label', 'Add to cart')" />
<form
class="add-to-cart-form"
t-attf-data-order-id="{{ order_id_safe }}"