feat: staff apps show the menu in the reader's language (plan 6R.L)

The waiters' phones and the counter show categories, products and every
choice (quick options, extras and sub-choices, preferences, shared sets,
ingredients, groups) in the signed-in person's language, falling back to
the stored text. Display only: carts, lines, tickets and the kitchen keep
the venue's text (ids, sub-choices by stored name). In the venue's own
language nothing changes.

- @xenia/access: menuText / useMenuText (mt, mt.choice, mt.line, mt.matches)
- /api/pos/menu carries translations for products, categories and choices
- shared ProductDialog takes a text() prop (the counter passes useMenuText)
- search finds a product by its name in any language (counter, waiter)
- waiter: useMenuNames for sent lines; picker, drawer, cart, summary,
  table lines, quantity / price history, favourites setup
- counter: categories, cards, dialog, cart lines, table lines, payment rows
- tests: access menuText, ordering search, test_pos per-language,
  e2e waiter.mjs and terminal.mjs 6R.L blocks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 20:18:10 +02:00
co-authored by Claude Opus 5.5
parent f107deca8c
commit 0840247768
29 changed files with 518 additions and 123 deletions
+16 -12
View File
@@ -5,7 +5,7 @@ import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
import { Allergens } from '@xenia/access'
import { Allergens, useMenuText } from '@xenia/access'
const FAV_CAT_ID = '__favorites__'
const SVC_CAT_ID = '__service__'
@@ -76,7 +76,8 @@ function ProductDetailModal({ product, onClose }) {
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
const initials = product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
const mt = useMenuText() // 6R.L: names in the waiter's language (display only)
const initials = mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
return (
<>
@@ -132,7 +133,7 @@ function ProductDetailModal({ product, onClose }) {
{/* Info */}
<div style={{ padding: '18px 20px 24px' }}>
<div style={{ fontSize: 20, fontWeight: 800, color: 'var(--text)', lineHeight: 1.2, marginBottom: 6 }}>
{product.name}
{mt(product)}
</div>
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--accent, var(--x-warning))', marginBottom: product.description ? 14 : 0 }}>
{money(product.base_price)}
@@ -142,7 +143,7 @@ function ProductDetailModal({ product, onClose }) {
fontSize: 14, color: 'var(--muted)', lineHeight: 1.6,
borderTop: '1px solid var(--border)', paddingTop: 12,
}}>
{product.description}
{mt(product, 'description')}
</div>
)}
<Allergens allergens={product.allergens} style={{ borderTop: '1px solid var(--border)', paddingTop: 12, marginTop: 12 }} />
@@ -189,6 +190,7 @@ function useLongPress(callback, delay = 2000) {
// ── Product card ──────────────────────────────────────────────────────────────
function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
const mt = useMenuText()
const canQuickAdd = productAllowsQuickAdd(product)
const onDetail = useCallback(() => onShowDetail(product), [onShowDetail, product])
@@ -214,13 +216,13 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
{product.image_url
? <img src={assetUrl(product.image_url)} alt="" className="product-btn__img" />
: <span className="product-btn__initials">
{product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
{mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
</span>
}
</div>
</div>
<div className="product-btn__info">
<span className="product-btn__name">{product.name}</span>
<span className="product-btn__name">{mt(product)}</span>
{product.tags?.length > 0 && (
<div className="product-btn__tags">
{product.tags.map(tag => (
@@ -263,6 +265,7 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
// ── Service Item Card ─────────────────────────────────────────────────────────
function ServiceItemCard({ product, customerCount, onAdd }) {
const { t } = useTranslation('waiter')
const mt = useMenuText()
const [qty, setQty] = useState(0)
function dec() { setQty(q => Math.max(0, q - 1)) }
@@ -290,7 +293,7 @@ function ServiceItemCard({ product, customerCount, onAdd }) {
{/* Top row: name + price */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
<span style={{ fontSize: 15, fontWeight: 700, color: 'var(--text)', lineHeight: 1.2, flex: 1, minWidth: 0 }}>
{product.name}
{mt(product)}
</span>
<span style={{ fontSize: 13, fontWeight: 600, color: hasPrice ? 'var(--x-warning)' : 'var(--muted)', flexShrink: 0 }}>
{hasPrice ? money(product.base_price) : t('picker.noCharge')}
@@ -438,6 +441,7 @@ function buildSections(parent, subcategories, directProducts) {
export default function ProductPicker({ categories, products, onAdd, onQuickAdd: onQuickAddProp, viewAllOpen, setViewAllOpen, customerCount, courses = [], globalCourseId = null, quickNotes }) {
const { t } = useTranslation('waiter')
const mt = useMenuText() // 6R.L: categories and products in the waiter's language
const navigate = useNavigate()
const favorites = useWaiterFavoritesStore(s => s.favorites)
@@ -575,7 +579,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
style={{ background: bg, color, border: isActive && cat.color ? `2px solid ${cat.color}` : undefined }}
onClick={() => selectCategory(cat.id)}
>
{cat.name}
{mt(cat)}
</button>
)
})}
@@ -670,7 +674,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
onClick={() => toggleSub(key)}
>
{accentColor && <span className="subcat-header__pill" style={{ background: accentColor }} />}
<span className="subcat-header__name">{section.name}</span>
<span className="subcat-header__name">{mt(section)}</span>
<span className="subcat-header__count">{sectionProducts.length}</span>
<svg
className="subcat-header__chevron"
@@ -761,7 +765,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
onClick={() => selectCategory(cat.id)}
>
<span className="cat-all-tile__overlay" style={{ background: overlay }} />
<span className="cat-all-tile__name">{cat.name}</span>
<span className="cat-all-tile__name">{mt(cat)}</span>
</button>
)
})}
@@ -773,7 +777,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
const taggedProducts = activeTag ? products.filter(p => (p.tags || []).includes(activeTag)) : []
const byCategory = taggedProducts.reduce((acc, p) => {
const cat = categories.find(c => c.id === p.category_id)
const key = cat?.name || t('picker.noCategory')
const key = (cat && mt(cat)) || t('picker.noCategory')
if (!acc[key]) acc[key] = []
acc[key].push(p)
return acc
@@ -826,7 +830,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
cursor: 'pointer', textAlign: 'left',
}}
>
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{p.name}</span>
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{mt(p)}</span>
<span style={{ fontSize: 13, color: 'var(--muted)' }}>{money(p.base_price)}</span>
</button>
))}