refactor: centralize locale resolution through PlatformSettingsService
Remove hardcoded locale fallbacks from templates and ensure all routes use the proper resolution chain (AdminSetting → Config → Default). Changes: - Add get_vendor_context() helper to vendor_pages.py mirroring shop pattern - Update all vendor routes to use get_vendor_context() with db session - Update shop routes to pass db session for locale resolution - Remove hardcoded fallbacks from shop/base.html and vendor/base.html - Templates now receive pre-resolved locale values from routes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -308,12 +308,12 @@
|
||||
{# 1. Log Configuration (must load first) #}
|
||||
<script src="{{ url_for('static', path='shared/js/log-config.js') }}"></script>
|
||||
|
||||
{# 2. Global Shop Configuration (currency/locale settings) #}
|
||||
{# 2. Global Shop Configuration (resolved via PlatformSettingsService) #}
|
||||
<script>
|
||||
window.SHOP_CONFIG = {
|
||||
locale: '{{ storefront_locale | default("fr-LU") }}',
|
||||
currency: '{{ storefront_currency | default("EUR") }}',
|
||||
language: '{{ request.state.language|default("fr") }}'
|
||||
locale: '{{ storefront_locale }}',
|
||||
currency: '{{ storefront_currency }}',
|
||||
language: '{{ request.state.language }}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
9
app/templates/vendor/base.html
vendored
9
app/templates/vendor/base.html
vendored
@@ -50,6 +50,15 @@
|
||||
<!-- 1. FIRST: Log Configuration -->
|
||||
<script src="{{ url_for('static', path='shared/js/log-config.js') }}"></script>
|
||||
|
||||
<!-- 1.5: Vendor Configuration (resolved via PlatformSettingsService) -->
|
||||
<script>
|
||||
window.VENDOR_CONFIG = {
|
||||
locale: '{{ storefront_locale }}',
|
||||
currency: '{{ storefront_currency }}',
|
||||
dashboardLanguage: '{{ dashboard_language }}'
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- 2. SECOND: Icons (before Alpine.js) -->
|
||||
<script src="{{ url_for('static', path='shared/js/icons.js') }}"></script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user