fix(storefront-i18n): dashboard widgets translate + correct customer-module key paths
Some checks failed
Some checks failed
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:
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"widget": {
|
||||
"rewards": {
|
||||
"title": "Treueprogramm",
|
||||
"subtitle_member": "Punkte und Prämien anzeigen",
|
||||
"subtitle_join": "Unserem Treueprogramm beitreten",
|
||||
"value_label": "Punktestand"
|
||||
}
|
||||
},
|
||||
"loyalty": {
|
||||
"module": {
|
||||
"name": "Treueprogramme",
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"widget": {
|
||||
"rewards": {
|
||||
"title": "Loyalty Rewards",
|
||||
"subtitle_member": "View your points & rewards",
|
||||
"subtitle_join": "Join our rewards program",
|
||||
"value_label": "Points Balance"
|
||||
}
|
||||
},
|
||||
"loyalty": {
|
||||
"module": {
|
||||
"name": "Loyalty Programs",
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"widget": {
|
||||
"rewards": {
|
||||
"title": "Programme de fidélité",
|
||||
"subtitle_member": "Voir vos points et récompenses",
|
||||
"subtitle_join": "Rejoindre notre programme de fidélité",
|
||||
"value_label": "Solde de points"
|
||||
}
|
||||
},
|
||||
"loyalty": {
|
||||
"module": {
|
||||
"name": "Programmes de Fidélité",
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
{
|
||||
"widget": {
|
||||
"rewards": {
|
||||
"title": "Treieprogramm",
|
||||
"subtitle_member": "Är Punkten a Belounungen kucken",
|
||||
"subtitle_join": "Eisem Treieprogramm bäitrieden",
|
||||
"value_label": "Punktenzuel"
|
||||
}
|
||||
},
|
||||
"loyalty": {
|
||||
"module": {
|
||||
"name": "Treieprogrammer",
|
||||
|
||||
@@ -51,6 +51,7 @@ class LoyaltyWidgetProvider:
|
||||
) -> list[StorefrontDashboardCard]:
|
||||
"""Provide the Loyalty Rewards card for the customer dashboard."""
|
||||
from app.modules.loyalty.models.loyalty_card import LoyaltyCard
|
||||
from app.utils.i18n import translate
|
||||
|
||||
card = (
|
||||
db.query(LoyaltyCard)
|
||||
@@ -62,17 +63,26 @@ class LoyaltyWidgetProvider:
|
||||
)
|
||||
|
||||
points = card.points_balance if card else None
|
||||
subtitle = "View your points & rewards" if card else "Join our rewards program"
|
||||
lang = context.language if context else None
|
||||
subtitle_key = (
|
||||
"loyalty.widget.rewards.subtitle_member"
|
||||
if card
|
||||
else "loyalty.widget.rewards.subtitle_join"
|
||||
)
|
||||
|
||||
return [
|
||||
StorefrontDashboardCard(
|
||||
key="loyalty.rewards",
|
||||
icon="gift",
|
||||
title="Loyalty Rewards",
|
||||
subtitle=subtitle,
|
||||
title=translate("loyalty.widget.rewards.title", lang),
|
||||
subtitle=translate(subtitle_key, lang),
|
||||
route="account/loyalty",
|
||||
value=points,
|
||||
value_label="Points Balance" if points is not None else None,
|
||||
value_label=(
|
||||
translate("loyalty.widget.rewards.value_label", lang)
|
||||
if points is not None
|
||||
else None
|
||||
),
|
||||
order=30,
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user