fix(storefront-i18n): dashboard widgets translate + correct customer-module key paths
Some checks failed
CI / ruff (push) Successful in 17s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has been cancelled

Two bugs from Test 5.1 on FR storefront dashboard:

1. Loyalty + Orders dashboard cards (`StorefrontDashboardCard.title`/
   `subtitle`/`value_label`) were hardcoded English. Added `language`
   to `WidgetContext`; customer dashboard route passes
   `request.state.language` through; loyalty and orders widget
   providers now call `translate(..., context.language)` with new
   `widget.*` i18n keys × 4 locales each.

2. Customer-module locale JSON has redundant top-level `customers`
   wrapper, so after the module-locale loader auto-namespaces under
   module code `customers`, the actual key path is
   `customers.customers.customer_number` (matches the existing
   `loyalty.loyalty.wallet.apple` pattern). My earlier sweep used the
   single-prefix path for 8 references — fixed all to double-prefix.

Both bugs were visible end-of-day yesterday after the api container
recreate landed `1bade6e6`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-29 20:45:46 +02:00
parent acbe2eff1a
commit 5f359283bc
15 changed files with 93 additions and 15 deletions

View File

@@ -1,4 +1,11 @@
{
"widget": {
"summary": {
"title": "Bestellungen",
"subtitle": "Bestellverlauf anzeigen",
"value_label": "Bestellungen gesamt"
}
},
"orders": {
"title": "Bestellungen",
"order": "Bestellung",

View File

@@ -1,4 +1,11 @@
{
"widget": {
"summary": {
"title": "Orders",
"subtitle": "View order history",
"value_label": "Total Orders"
}
},
"orders": {
"title": "Orders",
"order": "Order",

View File

@@ -1,4 +1,11 @@
{
"widget": {
"summary": {
"title": "Commandes",
"subtitle": "Voir l'historique des commandes",
"value_label": "Total des commandes"
}
},
"orders": {
"title": "Commandes",
"order": "Commande",

View File

@@ -1,4 +1,11 @@
{
"widget": {
"summary": {
"title": "Bestellungen",
"subtitle": "Bestellhistorik kucken",
"value_label": "Bestellunge gesamt"
}
},
"orders": {
"title": "Bestellungen",
"order": "Bestellung",

View File

@@ -51,6 +51,7 @@ class OrderWidgetProvider:
) -> list[StorefrontDashboardCard]:
"""Provide the Orders card for the customer dashboard."""
from app.modules.orders.models.customer_order_stats import CustomerOrderStats
from app.utils.i18n import translate
stats = (
db.query(CustomerOrderStats)
@@ -62,16 +63,17 @@ class OrderWidgetProvider:
)
total_orders = stats.total_orders if stats else 0
lang = context.language if context else None
return [
StorefrontDashboardCard(
key="orders.summary",
icon="shopping-bag",
title="Orders",
subtitle="View order history",
title=translate("orders.widget.summary.title", lang),
subtitle=translate("orders.widget.summary.subtitle", lang),
route="account/orders",
value=total_orders,
value_label="Total Orders",
value_label=translate("orders.widget.summary.value_label", lang),
order=10,
),
]