fix(i18n): convert remaining $t() to server-side _() and fix store dashboard language
Some checks failed
Some checks failed
- Convert storefront enrollment $t() calls to server-side _() to silence dev-toolbar warnings (welcome bonus + join button) - Fix store base template I18n.init() to use current_language (from middleware) instead of dashboard_language (hardcoded store config) so language changes take effect immediately - Switch admin loyalty routes to use get_admin_context() for proper i18n support - Switch store loyalty routes to use core get_store_context() from page_context - Pass program object to storefront enrollment context for server-side rendering - Add LANG-011 architecture rule: enforce $t()/_() over I18n.t() in templates - Fix duplicate file_pattern key in LANG-004 rule (YAML validation error) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,10 +24,8 @@ from app.api.deps import (
|
||||
get_db,
|
||||
get_resolved_store_code,
|
||||
)
|
||||
from app.modules.core.services.platform_settings_service import (
|
||||
platform_settings_service,
|
||||
)
|
||||
from app.modules.tenancy.models import Store, User
|
||||
from app.modules.core.utils.page_context import get_store_context
|
||||
from app.modules.tenancy.models import User
|
||||
from app.templates_config import templates
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -42,49 +40,6 @@ ROUTE_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# HELPER: Build Store Context
|
||||
# ============================================================================
|
||||
|
||||
|
||||
def get_store_context(
|
||||
request: Request,
|
||||
db: Session,
|
||||
current_user: User,
|
||||
store_code: str,
|
||||
**extra_context,
|
||||
) -> dict:
|
||||
"""Build template context for store loyalty pages."""
|
||||
# Load store from database
|
||||
store = db.query(Store).filter(Store.subdomain == store_code).first()
|
||||
|
||||
# Get platform defaults
|
||||
platform_config = platform_settings_service.get_storefront_config(db)
|
||||
|
||||
# Resolve with store override
|
||||
storefront_locale = platform_config["locale"]
|
||||
storefront_currency = platform_config["currency"]
|
||||
|
||||
if store and store.storefront_locale:
|
||||
storefront_locale = store.storefront_locale
|
||||
|
||||
context = {
|
||||
"request": request,
|
||||
"user": current_user,
|
||||
"store": store,
|
||||
"store_code": store_code,
|
||||
"storefront_locale": storefront_locale,
|
||||
"storefront_currency": storefront_currency,
|
||||
"dashboard_language": store.dashboard_language if store else "en",
|
||||
}
|
||||
|
||||
# Add any extra context
|
||||
if extra_context:
|
||||
context.update(extra_context)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# LOYALTY ROOT (Redirect to Terminal)
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user