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
+5 -3
View File
@@ -3,24 +3,26 @@
import { Minus, Plus } from 'lucide-react'
import { useFormat, useTranslation } from '@xenia/i18n'
import { IconButton, Select } from '@xenia/ui'
import { useMenuText } from '@xenia/access'
import { DISCOUNTS, unitOf } from './logic/cart'
export default function CartLine({ line, priced, product, canDiscount, onQty, onDiscount }) {
const { t } = useTranslation('terminal')
const { formatMoney } = useFormat()
const mt = useMenuText() // 6R.L: names in the cashier's language; the line keeps ids
const unit = product ? unitOf(product) : null
const step = unit ? unit.step : 1
const qtyText = unit ? `${Number(line.quantity).toFixed(step < 1 ? 1 : 0)} ${unit.label}` : `${line.quantity}×`
return (
<div className="px-3 py-2 border-b border-line grid gap-1" data-testid="cart-line" data-product={line.product_id}>
<div className="flex items-start gap-2">
<span className="flex-1 min-w-0 text-body font-medium text-ink">{product?.name ?? priced?.name}</span>
<span className="flex-1 min-w-0 text-body font-medium text-ink">{product ? mt(product) : priced?.name}</span>
<span className="text-body text-ink" data-testid="line-total">{priced ? formatMoney(priced.total) : '…'}</span>
</div>
{priced && (priced.entries.length > 0 || priced.removed.length > 0 || priced.notes) && (
<div className="text-label text-ink-2 grid">
{priced.entries.map((e, i) => <span key={i}>+ {e.name}{e.price ? ` (${formatMoney(e.price)})` : ''}</span>)}
{priced.removed.map(n => <span key={n} className="text-danger-ink">− {n}</span>)}
{priced.entries.map((e, i) => <span key={i}>+ {mt.choice(product, e.name)}{e.price ? ` (${formatMoney(e.price)})` : ''}</span>)}
{priced.removed.map(n => <span key={n} className="text-danger-ink">− {mt.choice(product, n)}</span>)}
{priced.notes && <span className="italic">“{priced.notes}”</span>}
</div>
)}
+9 -6
View File
@@ -14,7 +14,7 @@
import { useEffect, useMemo, useState } from 'react'
import { Globe, Info, LayoutGrid, Receipt, Search, ShoppingBag, X } from 'lucide-react'
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
import { useAllowed, useCan, useModule } from '@xenia/access'
import { useAllowed, useCan, useMenuText, useModule } from '@xenia/access'
import { splitChoices as splitChoicesOf } from '@xenia/ordering/split'
import { EmptyState, IconButton, Input, Spinner, useToast } from '@xenia/ui'
import { useLiveEvent } from '../../device/context'
@@ -51,6 +51,7 @@ export default function PosScreen() {
function Counter({ menu, t }) {
const { t: tc } = useTranslation('common')
const { language } = useLanguage()
const mt = useMenuText() // 6R.L: menu names in the cashier's language (display only)
const { formatMoney } = useFormat()
const [mode, setMode] = useState('sale') // sale | tables | online | receipts
const [tableId, setTableId] = useState(null) // the open table (tables mode)
@@ -181,7 +182,7 @@ function Counter({ menu, t }) {
<NavButton active={category == null && !query} onClick={() => { setCategory(null); setQuery('') }}>{t('pos.allProducts')}</NavButton>
{categories.map(c => (
<NavButton key={c.id} colour={c.color} active={category === c.id && !query} onClick={() => { setCategory(c.id); setQuery('') }} testId={`category-${c.id}`}>
{c.name}
{mt(c)}
</NavButton>
))}
</>
@@ -266,7 +267,7 @@ function Counter({ menu, t }) {
)}
{dialog && (
<ProductDialog product={dialog} orderType={atTable ? 'here' : orderType} onClose={() => setDialog(null)}
<ProductDialog product={dialog} orderType={atTable ? 'here' : orderType} onClose={() => setDialog(null)} text={mt}
onAdd={line => setCart(c => addLine(c, line))} />
)}
</div>
@@ -299,6 +300,8 @@ function NavButton({ active, colour, onClick, children, testId, count, tally })
function ProductCard({ product, onTap, onInfo }) {
const { t } = useTranslation('terminal')
const mt = useMenuText() // 6R.L: the cashier's language, display only
const name = mt(product)
const { formatMoney } = useFormat()
const unit = unitOf(product)
return (
@@ -306,13 +309,13 @@ function ProductCard({ product, onTap, onInfo }) {
<button type="button" onClick={onTap} className="flex-1 flex flex-col text-left active:scale-[0.98] transition-transform duration-fast">
{product.image_url
? <img src={product.image_url} alt="" loading="lazy" className="w-full aspect-[4/3] object-cover bg-surface-2" />
: <span className="w-full aspect-[4/3] bg-surface-2 flex items-center justify-center text-heading text-ink-3" aria-hidden="true">{product.name.slice(0, 1)}</span>}
: <span className="w-full aspect-[4/3] bg-surface-2 flex items-center justify-center text-heading text-ink-3" aria-hidden="true">{name.slice(0, 1)}</span>}
<span className="p-2 grid gap-0.5">
<span className="text-body font-medium text-ink line-clamp-2">{product.name}</span>
<span className="text-body font-medium text-ink line-clamp-2">{name}</span>
<span className="text-label text-ink-2">{formatMoney(product.price)}{unit ? ` / ${unit.label}` : ''}</span>
</span>
</button>
<IconButton label={t('pos.checkPrice', { name: product.name })} size="sm" variant="secondary" onClick={onInfo}
<IconButton label={t('pos.checkPrice', { name })} size="sm" variant="secondary" onClick={onInfo}
className="absolute top-1.5 right-1.5" data-testid="product-info">
<Info size={16} />
</IconButton>
+3 -1
View File
@@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from 'react'
import { Banknote, Repeat, ShoppingBag, Trash2, Utensils } from 'lucide-react'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, useToast } from '@xenia/ui'
import { useMenuText } from '@xenia/access'
import client from '../../api/client'
import CartLine from './CartLine'
import { setLineQty } from './logic/cart'
@@ -13,6 +14,7 @@ import { useDisplay, useQuote } from './usePos'
export default function SaleCart({ cart, setCart, orderType, setOrderType, byId, canDiscount, amountSplit = null }) {
const { t } = useTranslation('terminal')
const mt = useMenuText() // 6R.L: the cashier's language (the customer display keeps the venue's)
const { formatMoney } = useFormat()
const toast = useToast()
const [paying, setPaying] = useState(false)
@@ -79,7 +81,7 @@ export default function SaleCart({ cart, setCart, orderType, setOrderType, byId,
{paying && quote.quote && (
<PaymentDialog total={quote.quote.total} submit={submit} amountSplit={amountSplit}
rows={cart.map((l, i) => ({ label: `${l.quantity}× ${byId.get(l.product_id)?.name ?? ''}`, total: quote.quote.lines[i].total }))}
rows={cart.map((l, i) => ({ label: `${l.quantity}× ${mt(byId.get(l.product_id))}`, total: quote.quote.lines[i].total }))}
onClose={() => setPaying(false)}
onPaid={result => {
setPaying(false)
+8 -1
View File
@@ -7,6 +7,7 @@ import { useEffect, useState } from 'react'
import { ArrowLeft, Ban, Banknote, Check, CheckCircle2, Lock, Send, Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { useMenuText } from '@xenia/access'
import { Button, Dialog, EmptyState, IconButton, Spinner, useToast } from '@xenia/ui'
import client from '../../api/client'
import CartLine from './CartLine'
@@ -31,7 +32,13 @@ export default function TablePanel({ table, cart, setCart, byId, canDiscount, on
const [lastPay, setLastPay] = useState(null)
const [error, setError] = useState('')
const lines = orderLines(order)
const mt = useMenuText()
// 6R.L: shown in the cashier's language (the product's and its choices' texts); display only
const lines = orderLines(order).map(l => {
if (mt.same || l.system) return l
const p = byId.get(l.productId)
return { ...l, name: mt.line(p, l.name), options: l.options.map(o => mt.choice(p, o)) }
})
const sums = orderSums(lines)
const state = tableState(table)
const ready = cart.length > 0 && !quote.pending && !quote.error && quote.quote?.lines?.length === cart.length
+1
View File
@@ -49,6 +49,7 @@ export function orderLines(order) {
.filter(i => i.status === 'active' || i.status === 'ready' || i.status === 'paid' || i.status === 'split')
.map(i => ({
id: i.id,
productId: i.product_id, // 6R.L: the menu's product, for its name in the cashier's language
name: i.product_name ?? i.product?.name ?? '',
quantity: i.quantity,
unitType: i.unit_type,