75 lines
3.0 KiB
Markdown
75 lines
3.0 KiB
Markdown
---
|
|
phase: 12-i18n-bugfixes
|
|
plan: "01"
|
|
subsystem: frontend/i18n
|
|
tags: [i18n, alpine, e2e, browser-language, tdd]
|
|
dependency_graph:
|
|
requires: [11-ui-enhancements/11-03]
|
|
provides: [navigator.language-fallback, test_port_autofill-green]
|
|
affects: [imptune/templates/base.html, tests/e2e/test_i18n_toggle.py, tests/e2e/test_port_autofill.py]
|
|
tech_stack:
|
|
added: []
|
|
patterns: [IIFE-in-Alpine-store, playwright-browser-context-locale]
|
|
key_files:
|
|
created: []
|
|
modified:
|
|
- imptune/templates/base.html
|
|
- tests/e2e/test_i18n_toggle.py
|
|
- tests/e2e/test_port_autofill.py
|
|
decisions:
|
|
- 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
|
|
metrics:
|
|
duration: "~3 minutes"
|
|
completed: "2026-04-15"
|
|
tasks: 2
|
|
files_modified: 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
|
|
|
|
- [x] `imptune/templates/base.html` — modified with IIFE navigator.language fallback
|
|
- [x] `tests/e2e/test_i18n_toggle.py` — 3 new tests added, all pass
|
|
- [x] `tests/e2e/test_port_autofill.py` — URL fixed to /printers/new, test passes
|
|
- [x] Commits 86637f8, 5a02f4c, 2ab53f6 verified in git log
|
|
- [x] E2E suite: 10 passed
|
|
- [x] Non-E2E suite: 122 passed
|