{# app/templates/platform/sections/_pricing.html #}
{# Pricing section partial with multi-language support #}
{#
Parameters:
- pricing: PricingSection object (or dict) from CMS sections JSON
- lang: Current language code
- default_lang: Fallback language
- tiers: List of subscription tiers from DB (passed via context)
Requires: import with context (for _() locale function)
#}
{# Helper macro: resolve a TranslatableText field with fallback #}
{% macro _t(field, lang, default_lang, fallback='') %}
{%- if field and field.translations -%}
{{ field.translations.get(lang) or field.translations.get(default_lang) or fallback }}
{%- else -%}
{{ fallback }}
{%- endif -%}
{% endmacro %}
{% macro render_pricing(pricing, lang, default_lang, tiers) %}
{% if pricing and pricing.enabled %}
{# Section header #}
{% set title = _t(pricing.title, lang, default_lang, 'Simple, Transparent Pricing') %}
{{ title }}
{% set subtitle = _t(pricing.subtitle, lang, default_lang) %}
{% if subtitle|trim %}
{{ subtitle }}
{% endif %}
{# Pricing toggle (monthly/annual) #}
{% if pricing.use_subscription_tiers and tiers %}
{% set monthly_label = _t(pricing.monthly_label, lang, default_lang, 'Monthly') %}
{% set annual_label = _t(pricing.annual_label, lang, default_lang, 'Annual') %}
{% set save_text = _t(pricing.save_text, lang, default_lang, 'Save 2 months!') %}
{% set popular_badge = _t(pricing.popular_badge, lang, default_lang, 'Most Popular') %}
{% set cta_text = _t(pricing.cta_text, lang, default_lang, 'Start Free Trial') %}
{% set per_month = _t(pricing.per_month_label, lang, default_lang, '/month') %}
{% set per_year = _t(pricing.per_year_label, lang, default_lang, '/year') %}