- Fix sections editor not showing by converting isHomepage getter to property - Add Alpine Collapse plugin for accordion animations - Fix Quill editor content not syncing after page load - Add platform dropdown to content page edit form - Create shared templates config (app/templates_config.py) with i18n globals to make _() translation function available in Jinja2 macros - Fix pricing template field names (monthly_price → price_monthly) - Fix translation key (pricing.save_20 → pricing.save_months) - Add tiers context to CMS homepage route for pricing section - Fix architecture validation issues (language defaults, inline SVGs → $icon) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# app/templates_config.py
|
|
"""
|
|
Shared Jinja2 templates configuration.
|
|
|
|
All route modules should import `templates` from here to ensure
|
|
consistent globals (like translation function) are available.
|
|
"""
|
|
from pathlib import Path
|
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
from app.utils.i18n import (
|
|
LANGUAGE_FLAGS,
|
|
LANGUAGE_NAMES,
|
|
SUPPORTED_LANGUAGES,
|
|
DEFAULT_LANGUAGE,
|
|
create_translation_context,
|
|
)
|
|
|
|
# Templates directory
|
|
TEMPLATES_DIR = Path(__file__).parent / "templates"
|
|
|
|
# Create shared templates instance
|
|
templates = Jinja2Templates(directory=str(TEMPLATES_DIR))
|
|
|
|
# Add translation function to Jinja2 environment globals
|
|
# This makes _() available in all templates AND macros
|
|
_default_translator = create_translation_context(DEFAULT_LANGUAGE)
|
|
templates.env.globals["_"] = _default_translator
|
|
templates.env.globals["t"] = _default_translator # Alias
|
|
templates.env.globals["SUPPORTED_LANGUAGES"] = SUPPORTED_LANGUAGES
|
|
templates.env.globals["DEFAULT_LANGUAGE"] = DEFAULT_LANGUAGE
|
|
templates.env.globals["LANGUAGE_NAMES"] = LANGUAGE_NAMES
|
|
templates.env.globals["LANGUAGE_FLAGS"] = LANGUAGE_FLAGS
|