Skip to content

Add i18n support to System Install - #22

Open
Victor1890 wants to merge 15 commits into
pearOS-archlinux:mainfrom
Victor1890:feat/system-install-i18n-support
Open

Add i18n support to System Install#22
Victor1890 wants to merge 15 commits into
pearOS-archlinux:mainfrom
Victor1890:feat/system-install-i18n-support

Conversation

@Victor1890

Copy link
Copy Markdown
Contributor

What

Replaces 21 duplicated per-locale HTML pages with 6 shared templates + 1 JSON locale file. Splits monolithic engine.js into per-step modules, fixes navigation bugs, and adds i18n support with a lazy-loaded translation system.

Why

The system installer had no i18n architecture — each page was hardcoded English with no translation layer. Adding a new locale would require copying all 6 HTML pages and manually translating inline text. The monolithic engine.js (566 lines) mixed navigation, validation, disk operations, and UI logic, making maintenance difficult.

Bugs fixed:

  • Dead open_installer() function (called but never defined)
  • save_disk() returned a Promise instead of sync value (broke navigation)
  • Redundant createNavbar() call in init (double-rendered navbar)
  • i18n timing: translations loaded async but step-specific code ran before load (showed undefined keys)

What changed

Area Before After
Locale pages 21 HTML in app/lg/<locale>/ 6 templates + en_US.json
i18n Inline HTML per-locale app/i18n/*.json + i18n.js (XHR loader)
Navigation Inline onclick per button STEPS[] + data-nav orchestrator
engine.js 566 lines (everything) ~50 lines (core: getLng, STEPS, go, select_language, init)
Menu No back button Back button returns to language selection
License Duplicated in index.html + agreement.html Single source in agreement.html
HTML structure Broken nesting, missing closing tags Valid HTML5 with lang, alt attributes

Files

Added (8)

  • app/i18n/en_US.json — English translation strings
  • app/js/i18n.js — IIFE translation module (XHR loader, apply() for data-i18n)
  • app/js/menu.js — Menu checkbox logic, Alt key handler, install choice modal
  • app/js/apps.js — App launchers (GParted, Firefox, Packup, offline installer)
  • app/js/disk.js — Disk listing, selection, erase modal
  • app/js/agreement.js — Agreement modal functions
  • app/js/progress.js — Progress bar, install logging, close window
  • app/js/navbar.js — Dynamic navbar, clock, IPC actions

Modified (10)

  • app/js/engine.js — Trimmed to core navigation + init
  • app/js/examine.js — Simplified redirect
  • app/js/focus-fix.js — Cleaned up macOS focus fix
  • app/index.html — Trimmed to language selector only (39 lines)
  • app/css/assistant-styles.css — Fixed language selector, added .visually-hidden
  • main.js — Added POST_INSTALL_TEST env var support
  • package.json — Added test script for dev mode

Deleted (21)

  • app/lg/en/*.html (7 files)
  • app/lg/ro/*.html (7 files)
  • app/lg/cs/*.html (7 files)
  • app/js/movement.js — Dead code

Added (6 templates)

  • app/templates/menu.html — Main menu (data-step="menu")
  • app/templates/install.html — Install intro (data-step="install")
  • app/templates/agreement.html — License terms (data-step="agreement")
  • app/templates/disk.html — Disk selection (data-step="disk")
  • app/templates/progress.html — Install progress (data-step="progress")
  • app/templates/examining.html — 2s redirect (data-step="examining")

Behavior preserved

language select → menu → install → agreement → disk → progress → commit() → IPC run-post-setup. Test mode (POST_INSTALL_TEST=1) unchanged. All i18n keys reference data-i18n attributes with fallback to English text.

How to test

cd system_install/frontend
POST_INSTALL_TEST=1 npm run dev
Walk: pick language → Continue → menu (verify back button returns to language) → Continue → agreement → Continue → disk → Continue → progress → close. Hold Alt on menu to see offline/dual boot option.

- Remove app/lg/ folder with 21 HTML translation files
- Add app/i18n/en_US.json with all translation keys
- Add app/js/i18n.js module (IIFE, XHR loader, apply() for data-i18n)
- Add menu.js, apps.js, disk.js, agreement.js, progress.js
- Add navbar.js, examine.js, focus-fix.js
- Remove movement.js (dead code)
- Trim engine.js to core navigation and init
- Add app/templates/ folder with 6 HTML templates
- Each template loads engine.js, i18n.js, and step-specific modules
- Remove redundant onload handlers (engine init handles step-specific code)
- Move i18n.load() into engine init callback
- Ensure translations are loaded before step-specific code runs
- Remove redundant i18n.load() calls from templates
- Add POST_INSTALL_TEST env var check in main.js
- Open DevTools when test mode is enabled
- Add test script to package.json
- Add value attributes to option elements
- Improve language selection handling
@Victor1890
Victor1890 marked this pull request as ready for review July 29, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant