// The menu's languages (plan step 6.4, owner 2026-11-18): English and Greek, the same list as the // backend's core/menu_languages.py. Since 2026-11-21 every menu text is kept per language, the // venue's own included; "Default" in the editors is the venue's language. What is shown for an // item: the venue language's text, else the first language that has one (never mixed, never // machine-translated). export const MENU_LANGUAGES = ['el', 'en'] /** The languages a venue translates its menu into: every menu language but its own. */ export const translatedLanguages = venueLanguage => MENU_LANGUAGES.filter(l => l !== venueLanguage) /** A product's or category's text in a language: `names` / `descriptions` {lang: text} as the * backend resolves them for customer screens, else the base text. */ export const inLanguage = (texts, lang, base) => (texts && texts[lang]) || base /** The editors' "Default" (owner 2026-11-21): the venue's language. */ export const DEFAULT_LANGUAGE = 'default' /** The language a picker's choice edits: "default" → the venue's language. */ export const slotOf = (lang, venueLanguage) => (!lang || lang === DEFAULT_LANGUAGE ? (MENU_LANGUAGES.includes(venueLanguage) ? venueLanguage : MENU_LANGUAGES[0]) : lang) const filled = v => (typeof v === 'string' && v.trim() ? v.trim() : '') /** The text shown for an item {language: text}: the venue language's, else the first language * that has one, else `fallback` (the row's stored text, for items never given a language). */ export const shownText = (texts, venueLanguage, fallback = '') => filled(texts?.[venueLanguage]) || MENU_LANGUAGES.map(l => filled(texts?.[l])).find(Boolean) || filled(fallback)