Files
2026-04-15 17:57:12 +02:00

3.0 KiB

phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
phase plan subsystem tags dependency_graph tech_stack key_files decisions metrics
12-i18n-bugfixes 01 frontend/i18n
i18n
alpine
e2e
browser-language
tdd
requires provides affects
11-ui-enhancements/11-03
navigator.language-fallback
test_port_autofill-green
imptune/templates/base.html
tests/e2e/test_i18n_toggle.py
tests/e2e/test_port_autofill.py
added patterns
IIFE-in-Alpine-store
playwright-browser-context-locale
created modified
imptune/templates/base.html
tests/e2e/test_i18n_toggle.py
tests/e2e/test_port_autofill.py
IIFE pattern chosen over lazy property for Alpine store lang init — evaluates at store creation time (inside alpine:init), not at hydration time
playwright browser.new_context(locale=...) used to override navigator.language per test — avoids global page fixture contamination
duration completed tasks files_modified
~3 minutes 2026-04-15 2 3

Phase 12 Plan 01: i18n Bugfixes Summary

One-liner: IIFE-based navigator.language fallback in Alpine i18n store, plus test_port_autofill URL fix for /printers/new route.

What Was Built

Task 1: Browser language auto-detection in i18n store

Updated imptune/templates/base.html Alpine i18n store to replace the hardcoded 'fr' default with an IIFE that:

  1. Checks localStorage.getItem('imptune_lang') — returns the saved preference if present
  2. Falls back to navigator.language.startsWith('en') ? 'en' : 'fr' if no saved preference

Added 3 new E2E tests to tests/e2e/test_i18n_toggle.py covering:

  • test_navigator_language_en_sets_lang_en: locale=en-US + empty localStorage → lang='en'
  • test_navigator_language_fr_sets_lang_fr: locale=fr-FR + empty localStorage → lang='fr'
  • test_localstorage_wins_over_navigator_language: locale=en-US + localStorage='fr' → lang='fr'

Task 2: Fix test_port_autofill navigating to /printers/new

Updated tests/e2e/test_port_autofill.py to navigate to /printers/new instead of /printers. Plan 11-01 moved the add-printer form to the new route; the test was deferred in deferred-items.md and fixed here as planned.

Test Results

  • E2E suite: 10/10 passed (was 6/7 before this plan — test_port_autofill was failing)
  • Non-E2E suite: 122/122 passed (no regressions)

Commits

Hash Type Description
86637f8 test add failing tests for navigator.language auto-detection (TDD RED)
5a02f4c feat update i18n store lang init to use navigator.language fallback (TDD GREEN)
2ab53f6 fix update test_port_autofill to navigate to /printers/new

Deviations from Plan

None — plan executed exactly as written.

Self-Check: PASSED

  • imptune/templates/base.html — modified with IIFE navigator.language fallback
  • tests/e2e/test_i18n_toggle.py — 3 new tests added, all pass
  • tests/e2e/test_port_autofill.py — URL fixed to /printers/new, test passes
  • Commits 86637f8, 5a02f4c, 2ab53f6 verified in git log
  • E2E suite: 10 passed
  • Non-E2E suite: 122 passed