Files
ImpTune/.planning/phases/12-i18n-bugfixes/12-01-PLAN.md
T
kawaandClaude Sonnet 4.6 ef8fbc9692 docs(12-i18n-bugfixes): create phase plan
2 plans: browser lang auto-detection + fix test_port_autofill (wave 1),
full template i18n coverage across 13 templates (wave 2).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 15:18:53 +02:00

6.0 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
phase plan type wave depends_on files_modified autonomous requirements must_haves
12-i18n-bugfixes 01 execute 1
imptune/templates/base.html
tests/e2e/test_port_autofill.py
true
truths artifacts key_links
When a user's browser is set to English (navigator.language starts with 'en'), the UI loads in English by default without touching the toggle
When localStorage has no saved language preference, the browser's navigator.language is used as the initial language
When localStorage does have a saved preference, it wins over navigator.language
test_port_autofill passes in CI — navigates to /printers/new (not /printers)
path provides contains
imptune/templates/base.html i18n store with navigator.language fallback navigator.language
path provides contains
tests/e2e/test_port_autofill.py Fixed E2E test navigating to /printers/new /printers/new
from to via pattern
imptune/templates/base.html Alpine.store('i18n').lang localStorage.getItem || navigator.language fallback navigator.language
Fix the two remaining correctness bugs from Phase 11: (1) browser language auto-detection not honouring navigator.language when no localStorage preference exists, and (2) the pre-existing test_port_autofill E2E failure caused by Phase 11 moving the add-printer form to /printers/new.

Purpose: Users whose browser is set to English should get the English UI on first visit, without manually clicking the toggle. The E2E suite should be fully green. Output: Updated base.html i18n store, fixed test_port_autofill.py.

<execution_context> @C:/Users/SebastienQUEROL/.claude/get-shit-done/workflows/execute-plan.md @C:/Users/SebastienQUEROL/.claude/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/11-ui-enhancements/11-03-SUMMARY.md @.planning/phases/11-ui-enhancements/deferred-items.md Task 1: Browser language auto-detection in i18n store imptune/templates/base.html - When localStorage key 'imptune_lang' is absent and navigator.language starts with 'en', lang initialises to 'en' - When localStorage key 'imptune_lang' is absent and navigator.language starts with 'fr' (or anything else), lang initialises to 'fr' - When localStorage key 'imptune_lang' is 'fr', it wins over navigator.language === 'en-US' - When localStorage key 'imptune_lang' is 'en', it wins over navigator.language === 'fr-FR' In imptune/templates/base.html, inside the alpine:init script, update the i18n store's lang initialisation line. Currently:

lang: localStorage.getItem('imptune_lang') || 'fr',

Change to a function-based initialisation that checks navigator.language when localStorage is absent:

lang: (() => { const saved = localStorage.getItem('imptune_lang'); if (saved) return saved; return navigator.language && navigator.language.startsWith('en') ? 'en' : 'fr'; })(),

This is a single targeted change. Do not modify anything else in base.html. The toggle() method, translations object, and all x-text bindings remain unchanged.

Note: Do NOT use a top-level property shorthand that would require Alpine to evaluate it lazily — the IIFE pattern evaluates at store creation time, which is the correct moment (stores are created inside alpine:init, before any hydration). cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/test_i18n_toggle.py -x -q 2>&1 | tail -10 - base.html i18n store lang field uses IIFE with navigator.language fallback - All 2 existing test_i18n_toggle.py tests still pass (they test toggle + persistence, not initial detection) - Manual verification: open a fresh browser with no imptune_lang in localStorage; if browser language is English, nav shows "Drivers" not "Pilotes"

Task 2: Fix test_port_autofill navigating to /printers/new tests/e2e/test_port_autofill.py - test_port_autofill navigates to /printers/new (not /printers) - Typing an IP into input[name='ip_address'] auto-populates port_name with 'IP_192_168_1_100' - Test passes on chromium In tests/e2e/test_port_autofill.py, change the page.goto line:

BEFORE: page.goto(f"{live_server}/printers", wait_until="domcontentloaded") AFTER: page.goto(f"{live_server}/printers/new", wait_until="domcontentloaded")

That is the only change needed. The input[name='ip_address'] and port_name assertions remain exactly as is — they already match the form markup in printers_new.html.

Context: Plan 11-01 moved the add-printer form from /printers to /printers/new. The E2E test was deferred (logged in deferred-items.md) because it was a pre-existing failure at the time of 11-04 execution. Phase 12 is the correct place to fix it. cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/test_port_autofill.py -x -q 2>&1 | tail -10 - test_port_autofill[chromium] passes - The one-line URL fix is the only change in the file

Run the full E2E suite to confirm no regressions: cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/ -q 2>&1 | tail -15

All 7 E2E tests should pass (the 7th was the previously failing test_port_autofill[chromium]).

<success_criteria>

  • base.html i18n store reads navigator.language as fallback when localStorage is empty
  • test_port_autofill[chromium] passes
  • Full E2E suite: 7/7 passing
  • Non-E2E test suite unchanged and passing </success_criteria>
After completion, create `.planning/phases/12-i18n-bugfixes/12-01-SUMMARY.md`