fix: language switcher stuck in French on store dashboard
Some checks failed
CI / ruff (push) Successful in 11s
CI / pytest (push) Failing after 44m35s
CI / validate (push) Successful in 23s
CI / dependency-scanning (push) Successful in 28s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

Three compounding bugs prevented language switching on the store dashboard:
- Cookie missing path="/", scoping it to the API endpoint path only
- STORE frontend resolution chain ignored the cookie entirely
- Store header used inline x-data with wrong language names instead of shared languageSelector()

Also updates architecture doc with correct per-frontend resolution priorities,
cookie name, API endpoint path, and file references.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 05:30:25 +01:00
parent cd935988c4
commit 0389294b1a
4 changed files with 35 additions and 51 deletions

View File

@@ -37,33 +37,7 @@
</li>
<!-- Language selector -->
<li class="relative" x-data="{
isLangOpen: false,
currentLang: '{{ request.state.language|default("fr") }}',
languages: ['en', 'fr', 'de', 'lb'],
languageNames: { 'en': 'English', 'fr': 'Francais', 'de': 'Deutsch', 'lb': 'Letzebuerg' },
languageFlags: { 'en': 'gb', 'fr': 'fr', 'de': 'de', 'lb': 'lu' },
async setLanguage(lang) {
if (lang === this.currentLang) {
this.isLangOpen = false;
return;
}
try {
const response = await fetch('/api/v1/platform/language/set', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ language: lang })
});
if (response.ok) {
this.currentLang = lang;
window.location.reload();
}
} catch (error) {
console.error('Failed to set language:', error);
}
this.isLangOpen = false;
}
}">
<li class="relative" x-data="languageSelector('{{ request.state.language|default('fr') }}')">
<button
@click="isLangOpen = !isLangOpen"
@click.outside="isLangOpen = false"
@@ -179,4 +153,4 @@
</li>
</ul>
</div>
</header>
</header>

View File

@@ -351,15 +351,20 @@ def get_jinja2_globals(language: str = None) -> dict:
def resolve_store_dashboard_language(
user_preferred: str | None,
store_dashboard: str | None,
cookie_language: str | None = None,
) -> str:
"""
Resolve language for store dashboard.
Priority:
1. User's preferred_language (if set)
2. Store's dashboard_language
3. System default (fr)
1. Cookie (explicit UI action via language switcher)
2. User's preferred_language (DB preference from profile settings)
3. Store's dashboard_language
4. System default (fr)
"""
if cookie_language and cookie_language in SUPPORTED_LANGUAGES:
return cookie_language
if user_preferred and user_preferred in SUPPORTED_LANGUAGES:
return user_preferred