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:
@@ -111,11 +111,9 @@ language_rules:
|
||||
function languageSelector(currentLang, enabledLanguages) { ... }
|
||||
window.languageSelector = languageSelector;
|
||||
pattern:
|
||||
file_pattern: "static/shop/js/shop-layout.js"
|
||||
required_patterns:
|
||||
- "function languageSelector"
|
||||
- "window.languageSelector"
|
||||
file_pattern: "static/vendor/js/init-alpine.js"
|
||||
file_patterns:
|
||||
- "static/shop/js/shop-layout.js"
|
||||
- "static/vendor/js/init-alpine.js"
|
||||
required_patterns:
|
||||
- "function languageSelector"
|
||||
- "window.languageSelector"
|
||||
@@ -247,3 +245,26 @@ language_rules:
|
||||
pattern:
|
||||
file_pattern: "static/locales/*.json"
|
||||
check: "valid_json"
|
||||
|
||||
- id: "LANG-011"
|
||||
name: "Use $t() not I18n.t() in HTML templates"
|
||||
severity: "error"
|
||||
description: |
|
||||
In HTML templates, never use I18n.t() directly. It evaluates once
|
||||
and does NOT re-evaluate when translations finish loading async.
|
||||
|
||||
WRONG (non-reactive, shows raw key then updates):
|
||||
<span x-text="I18n.t('module.key')"></span>
|
||||
|
||||
RIGHT (reactive, updates when translations load):
|
||||
<span x-text="$t('module.key')"></span>
|
||||
|
||||
BEST (server-side, zero flash):
|
||||
<span>{{ _('module.key') }}</span>
|
||||
|
||||
Note: I18n.t() is fine in .js files where it's called inside
|
||||
async callbacks after I18n.init() has completed.
|
||||
pattern:
|
||||
file_pattern: "**/*.html"
|
||||
anti_patterns:
|
||||
- "I18n.t("
|
||||
|
||||
Reference in New Issue
Block a user