// The waiter app's translations instance (plan step 4.1); its texts are keys in the `waiter` // namespace of @xenia/i18n (step 4.5). Components use useTranslation('waiter'); code outside // components (services, stores, native glue) uses tw('key'). import { createFormatters, createI18n } from '@xenia/i18n' export const i18n = createI18n({ defaultNS: 'common' }) /** Translate a waiter key outside a component (the current language). */ export const tw = (key, options) => i18n.t(key, { ns: 'waiter', ...options }) // Money outside a component's useFormat() (helpers shared by several components): the current // language's format, the venue currency (€). Inside components prefer useFormat().formatMoney. const formatters = new Map() export function money(value) { const lng = i18n.language if (!formatters.has(lng)) formatters.set(lng, createFormatters({ language: lng })) return formatters.get(lng).formatMoney(Number(value) || 0) }