import type { PaywallDisplayPlan } from '@funnelsgrove/payments'; /** Translate recognized display labels while retaining arbitrary catalog copy and payment data. */ export function localizePaywallPlanLabels(plan: PaywallDisplayPlan, labels: Record): PaywallDisplayPlan { const translate = (value: string) => typeof labels[value] === 'string' ? labels[value] : value; return { ...plan, title: translate(plan.title), priceLabel: translate(plan.priceLabel), basePriceLabel: translate(plan.basePriceLabel), oldPriceLabel: plan.oldPriceLabel ? translate(plan.oldPriceLabel) : plan.oldPriceLabel, checkoutSummaryLabel: plan.checkoutSummaryLabel ? translate(plan.checkoutSummaryLabel) : plan.checkoutSummaryLabel, featuredTag: plan.featuredTag ? translate(plan.featuredTag) : plan.featuredTag, }; }