feat(menu): the menu in English and Greek (platform-v2 step 6.4, D-29)
- products.translations / categories.translations (Alembic 0033, core/menu_languages.py: el + en,
name / description / quick options by their base name; catalog.translation). Empty = the text
as typed; no machine translation (owner).
- In the manager's product editor ("In English" / "In Greek", quick extras), the category dialog,
and a menu board's Language (signage MenuContent.language).
- Customer screens only: cloud snapshot names / descriptions per language (C-2), the menu tablet's
EL / EN switch the names (localize), signage boards; tickets, KDS, counter, phones keep the base.
- Catalogue bundles carry translations; @xenia/access menuLanguages.js (a backend test compares).
- e2e: manager (the other language saved), menu tablet (EN / EL names), QR table (English on
the menu, the base name on the kitchen's order, Greek page as typed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ Lock behaviour (unchanged):
|
||||
- cloud sets locked=true → lock_pending while a workday is open, locked once it closes
|
||||
- expiry past grace / site deactivated → likewise never mid-service
|
||||
"""
|
||||
from core import allergens, sales_points
|
||||
from core import allergens, menu_languages, sales_points
|
||||
from core.access.queries import holders_filter
|
||||
from core.timeutil import utcnow
|
||||
import asyncio
|
||||
@@ -288,11 +288,14 @@ def menu_snapshot(db) -> tuple[dict, list]:
|
||||
"digital_available": bool(p.digital_available),
|
||||
"digital_image_url": p.digital_image_url,
|
||||
"image_url": p.image_url,
|
||||
"quick_options": [{"id": o.id, "name": o.name, "price": o.price} for o in p.quick_options],
|
||||
"quick_options": [{"id": o.id, "name": o.name, "price": o.price,
|
||||
"names": menu_languages.quick_texts(o.name, menu_languages.of(p))} for o in p.quick_options],
|
||||
"allergens": allergens.of(p), # 6.3: {key: "contains" | "may_contain"}
|
||||
**menu_languages.product_texts(p), # 6.4: names / descriptions {language: text}
|
||||
})
|
||||
if product_list:
|
||||
payload_categories.append({"id": cat.id, "name": cat.name, "sort_order": cat.sort_order,
|
||||
"names": menu_languages.texts(cat.name, menu_languages.of(cat), "name"),
|
||||
"products": product_list})
|
||||
# delivery areas and fee rules (S.3): the cloud applies them at checkout with the same
|
||||
# engine (services/fees.py); the venue's time zone says what "22:00" and "Saturday" mean
|
||||
|
||||
@@ -15,7 +15,7 @@ counter's: listed ids first in that order, the rest after them in the catalogue'
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from core import sales_points
|
||||
from core import menu_languages, sales_points
|
||||
|
||||
|
||||
def _descendants(cats_by_parent: dict, roots: list[int]) -> set[int]:
|
||||
@@ -78,10 +78,15 @@ def resolve(db, content: dict, now=None) -> dict:
|
||||
prices = dict(zip([p.id for p in products], unit_prices(db, products, point, now=now))) if point and products else {}
|
||||
badges = {int(k): v for k, v in (content.get("badges") or {}).items() if str(k).isdigit()}
|
||||
|
||||
lang = content.get("language") # 6.4: the board's language; None = the base texts
|
||||
|
||||
def text(row, base, field):
|
||||
return menu_languages.texts(base, menu_languages.of(row), field).get(lang, base) if lang else base
|
||||
|
||||
def item(p):
|
||||
image = media_store.image_of(p.media) if content.get("show_photos") else None
|
||||
return {"id": p.id, "name": p.digital_name or p.name,
|
||||
"description": (p.digital_description or p.description or None) if content.get("show_descriptions") else None,
|
||||
return {"id": p.id, "name": text(p, p.digital_name or p.name, "name"),
|
||||
"description": text(p, p.digital_description or p.description or None, "description") if content.get("show_descriptions") else None,
|
||||
"price": round(prices[p.id], 2) if p.id in prices else None,
|
||||
"available": bool(p.is_available), "image": image["card"] if image else None,
|
||||
"badge": badges.get(p.id)}
|
||||
@@ -90,7 +95,7 @@ def resolve(db, content: dict, now=None) -> dict:
|
||||
groups: dict = {}
|
||||
for p in products:
|
||||
groups.setdefault(p.primary_category_id, []).append(p)
|
||||
out = [{"category": {"id": cid, "name": by_id[cid].name} if cid in by_id else None,
|
||||
out = [{"category": {"id": cid, "name": text(by_id[cid], by_id[cid].name, "name")} if cid in by_id else None,
|
||||
"items": [item(p) for p in sorted(ps, key=prod_key)]}
|
||||
for cid, ps in sorted(groups.items(), key=lambda kv: cat_key(kv[0]))]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user