velxio/frontend/src/App.tsx

172 lines
8.1 KiB
TypeScript
Raw Normal View History

feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
import { useEffect, type ReactElement } from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate, useLocation } from 'react-router-dom';
2026-03-07 01:32:24 +07:00
import { LandingPage } from './pages/LandingPage';
import { EditorPage } from './pages/EditorPage';
import { ExamplesPage } from './pages/ExamplesPage';
import { DocsPage } from './pages/DocsPage';
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
// Login, Register, ForgotPassword, ResetPassword, Admin, UserProfile,
// Project, ProjectById — moved to the pro overlay in Phase 3 of the
// OSS split. They register themselves via registerProRoutes() inside
// mountPro() and appear under /login, /admin, /:username etc. only when
// the overlay is loaded.
import { ExampleDetailPage } from './pages/ExampleDetailPage';
feat(examples): /example/<id> route with pinned URL Mirror of the /project/<uuid> pattern but for built-in examples. Loading an example used to navigate to a generic /editor and lose all trace of which example was loaded — same URL whether you clicked Blink or Doom, nothing shareable, no back-button history. New page: pages/ExampleEditorPage.tsx - Route: /example/:exampleId (singular, distinct from the plural /examples/<id> landing). - useEffect calls loadExample(...) once when exampleId changes, guarded by a ref so React strict-mode's double-effect doesn't re-load (which would clobber any edits the user made). - Renders <EditorPage /> after the load completes — same as how ProjectByIdPage stays mounted at /project/<uuid> after load. - SEO: title + description per example, canonical URL points at /example/<id>. - 404 state for unknown ids (typo'd link, deleted example). - Inline install progress while libraries fetch — the overlay UI moved here from ExamplesPage/ExampleDetailPage so progress is visible right at the URL you'll bookmark. App.tsx — registered the new route alongside the existing landing. Both coexist on purpose: /examples/<id> = SEO landing page (preview, badges, "Open in Simulator" CTA). Indexed by Google (130 URLs already in sitemap.xml). /example/<id> = live editor with the example pre-loaded; URL stays pinned so the link is shareable + bookmarkable like a saved project URL. ExamplesPage — gallery now navigates to /example/<id> instead of calling loadExample directly. Also drops the install-overlay block (progress UI is on ExampleEditorPage now). ExampleDetailPage — "Open in Simulator" navigates to /example/<id> instead of loading directly. Drops its own install overlay too. Side effect: this also kills the data-loss bug from 95f2aa9 in a second way. Even if a future change forgets to call clearCurrentProject() somewhere, navigating into ExampleEditorPage forces a fresh page transition — the previous project's state + the auto-save subscription don't survive into the example session. Build verified (vite OSS+pro, 285 SEO pages prerendered). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 10:14:36 +07:00
import { ExampleEditorPage } from './pages/ExampleEditorPage';
import { ArduinoSimulatorPage } from './pages/ArduinoSimulatorPage';
import { ArduinoEmulatorPage } from './pages/ArduinoEmulatorPage';
import { AtmegaSimulatorPage } from './pages/AtmegaSimulatorPage';
import { ArduinoMegaSimulatorPage } from './pages/ArduinoMegaSimulatorPage';
2026-04-29 20:28:31 +07:00
import { Attiny85SimulatorPage } from './pages/Attiny85SimulatorPage';
import { CircuitSimulatorPage } from './pages/CircuitSimulatorPage';
import { SpiceSimulatorPage } from './pages/SpiceSimulatorPage';
import { ElectronicsSimulatorPage } from './pages/ElectronicsSimulatorPage';
import { CustomChipSimulatorPage } from './pages/CustomChipSimulatorPage';
import { Esp32SimulatorPage } from './pages/Esp32SimulatorPage';
import { Esp32S3SimulatorPage } from './pages/Esp32S3SimulatorPage';
import { Esp32C3SimulatorPage } from './pages/Esp32C3SimulatorPage';
import { RaspberryPiPicoSimulatorPage } from './pages/RaspberryPiPicoSimulatorPage';
import { RaspberryPiSimulatorPage } from './pages/RaspberryPiSimulatorPage';
import { Velxio2Page } from './pages/Velxio2Page';
import { Velxio25Page } from './pages/Velxio25Page';
import { Velxio3Page } from './pages/Velxio3Page';
import { AboutPage } from './pages/AboutPage';
import { PricingPlaceholder } from './pages/PricingPlaceholder';
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
import { LocaleSync } from './i18n/LocaleSync';
import { NON_DEFAULT_LOCALES } from './i18n/config';
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
import { useProRoutes } from './lib/proRoutes';
import { triggerSessionCheck } from './lib/proSession';
import './App.css';
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
/**
* Single source of truth for the route tree. Each entry is registered
* twice in <Routes> below: once at the root (default locale) and once
* nested under each non-default locale prefix (e.g. `/es/editor`).
*
* Index entries (path === '') belong to the locale-prefixed parent's
* `index` slot they render at exactly `/<locale>/`.
*/
// In Tauri desktop builds the marketing landing page is a disorienting
// first screen — users opened the desktop app to land in the editor.
// `/` redirects there. Web builds still see the LandingPage.
const ROOT_ELEMENT: ReactElement = import.meta.env.VITE_DESKTOP ? (
<Navigate to="/editor" replace />
) : (
<LandingPage />
);
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
const ROUTES: { path: string; element: ReactElement; index?: boolean }[] = [
{ path: '/', element: ROOT_ELEMENT, index: true },
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
{ path: 'editor', element: <EditorPage /> },
{ path: 'examples', element: <ExamplesPage /> },
feat(examples): /example/<id> route with pinned URL Mirror of the /project/<uuid> pattern but for built-in examples. Loading an example used to navigate to a generic /editor and lose all trace of which example was loaded — same URL whether you clicked Blink or Doom, nothing shareable, no back-button history. New page: pages/ExampleEditorPage.tsx - Route: /example/:exampleId (singular, distinct from the plural /examples/<id> landing). - useEffect calls loadExample(...) once when exampleId changes, guarded by a ref so React strict-mode's double-effect doesn't re-load (which would clobber any edits the user made). - Renders <EditorPage /> after the load completes — same as how ProjectByIdPage stays mounted at /project/<uuid> after load. - SEO: title + description per example, canonical URL points at /example/<id>. - 404 state for unknown ids (typo'd link, deleted example). - Inline install progress while libraries fetch — the overlay UI moved here from ExamplesPage/ExampleDetailPage so progress is visible right at the URL you'll bookmark. App.tsx — registered the new route alongside the existing landing. Both coexist on purpose: /examples/<id> = SEO landing page (preview, badges, "Open in Simulator" CTA). Indexed by Google (130 URLs already in sitemap.xml). /example/<id> = live editor with the example pre-loaded; URL stays pinned so the link is shareable + bookmarkable like a saved project URL. ExamplesPage — gallery now navigates to /example/<id> instead of calling loadExample directly. Also drops the install-overlay block (progress UI is on ExampleEditorPage now). ExampleDetailPage — "Open in Simulator" navigates to /example/<id> instead of loading directly. Drops its own install overlay too. Side effect: this also kills the data-loss bug from 95f2aa9 in a second way. Even if a future change forgets to call clearCurrentProject() somewhere, navigating into ExampleEditorPage forces a fresh page transition — the previous project's state + the auto-save subscription don't survive into the example session. Build verified (vite OSS+pro, 285 SEO pages prerendered). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 10:14:36 +07:00
// /examples/<id> = SEO landing (preview, badges, "Open in Simulator" CTA).
// /example/<id> = live editor with the example pre-loaded; the URL
// stays pinned so links are shareable + bookmarkable.
// Singular vs plural is intentional — Google indexes the plural landings.
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
{ path: 'examples/:exampleId', element: <ExampleDetailPage /> },
feat(examples): /example/<id> route with pinned URL Mirror of the /project/<uuid> pattern but for built-in examples. Loading an example used to navigate to a generic /editor and lose all trace of which example was loaded — same URL whether you clicked Blink or Doom, nothing shareable, no back-button history. New page: pages/ExampleEditorPage.tsx - Route: /example/:exampleId (singular, distinct from the plural /examples/<id> landing). - useEffect calls loadExample(...) once when exampleId changes, guarded by a ref so React strict-mode's double-effect doesn't re-load (which would clobber any edits the user made). - Renders <EditorPage /> after the load completes — same as how ProjectByIdPage stays mounted at /project/<uuid> after load. - SEO: title + description per example, canonical URL points at /example/<id>. - 404 state for unknown ids (typo'd link, deleted example). - Inline install progress while libraries fetch — the overlay UI moved here from ExamplesPage/ExampleDetailPage so progress is visible right at the URL you'll bookmark. App.tsx — registered the new route alongside the existing landing. Both coexist on purpose: /examples/<id> = SEO landing page (preview, badges, "Open in Simulator" CTA). Indexed by Google (130 URLs already in sitemap.xml). /example/<id> = live editor with the example pre-loaded; URL stays pinned so the link is shareable + bookmarkable like a saved project URL. ExamplesPage — gallery now navigates to /example/<id> instead of calling loadExample directly. Also drops the install-overlay block (progress UI is on ExampleEditorPage now). ExampleDetailPage — "Open in Simulator" navigates to /example/<id> instead of loading directly. Drops its own install overlay too. Side effect: this also kills the data-loss bug from 95f2aa9 in a second way. Even if a future change forgets to call clearCurrentProject() somewhere, navigating into ExampleEditorPage forces a fresh page transition — the previous project's state + the auto-save subscription don't survive into the example session. Build verified (vite OSS+pro, 285 SEO pages prerendered). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 10:14:36 +07:00
{ path: 'example/:exampleId', element: <ExampleEditorPage /> },
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
{ path: 'docs', element: <DocsPage /> },
{ path: 'docs/:section', element: <DocsPage /> },
// SEO landing pages — keyword-targeted
{ path: 'circuit-simulator', element: <CircuitSimulatorPage /> },
{ path: 'spice-simulator', element: <SpiceSimulatorPage /> },
{ path: 'electronics-simulator', element: <ElectronicsSimulatorPage /> },
{ path: 'custom-chip-simulator', element: <CustomChipSimulatorPage /> },
{ path: 'attiny85-simulator', element: <Attiny85SimulatorPage /> },
{ path: 'arduino-simulator', element: <ArduinoSimulatorPage /> },
{ path: 'arduino-emulator', element: <ArduinoEmulatorPage /> },
{ path: 'atmega328p-simulator', element: <AtmegaSimulatorPage /> },
{ path: 'arduino-mega-simulator', element: <ArduinoMegaSimulatorPage /> },
{ path: 'esp32-simulator', element: <Esp32SimulatorPage /> },
{ path: 'esp32-s3-simulator', element: <Esp32S3SimulatorPage /> },
{ path: 'esp32-c3-simulator', element: <Esp32C3SimulatorPage /> },
{ path: 'raspberry-pi-pico-simulator', element: <RaspberryPiPicoSimulatorPage /> },
{ path: 'raspberry-pi-simulator', element: <RaspberryPiSimulatorPage /> },
{ path: 'v2', element: <Velxio2Page /> },
{ path: 'v2-5', element: <Velxio25Page /> },
{ path: 'v3', element: <Velxio3Page /> },
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
{ path: 'about', element: <AboutPage /> },
// Pricing — placeholder by default; private overlays portal-inject the real page
{ path: 'pricing', element: <PricingPlaceholder /> },
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
// project/:id, :username/:projectName, :username — also moved to the
// pro overlay (project persistence + public profiles are pro features).
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
];
/**
* The default locale (English) is served at the root with NO `/en` prefix, so
* `/en/...` matches no route and renders blank. People reasonably guess `/en/`
* by analogy with `/es/`, `/zh-cn/`, redirect them to the prefix-free path
* (`/en/project/x` `/project/x`, `/en` `/`) instead of a blank page. This
* keeps the canonical no-prefix English URLs (good for SEO) while handling the
* guessed ones gracefully.
*/
function EnPrefixRedirect() {
const { pathname, search, hash } = useLocation();
const stripped = pathname.replace(/^\/en(?=\/|$)/, '');
return <Navigate to={(stripped || '/') + search + hash} replace />;
}
function App() {
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
// Pro overlay registers extra routes (login, register, admin, profile,
// project-by-slug, …) via registerProRoutes() inside mountPro(). The
// subscription is sync external store, so any registration after the
// initial render triggers a re-render — no Not-Found flash for routes
// the overlay was about to add.
const proRoutes = useProRoutes();
const allRoutes = [...ROUTES, ...proRoutes];
useEffect(() => {
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
// Pro overlay's mountPro() registers a session-check callback that
// resolves the JWT cookie into a user object. No-op in OSS without
// the overlay.
triggerSessionCheck();
// #root-seo is a static SEO fallback in index.html (position:absolute,
// visibility:hidden). It still contributes to document scrollHeight, so
// every page got a phantom scroll the size of the prerendered SEO body.
document.getElementById('root-seo')?.remove();
}, []);
return (
<Router>
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
<LocaleSync>
<Routes>
{/* Default locale (English) — no URL prefix. */}
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
{allRoutes.map((r) =>
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
r.index ? (
<Route key="root" path="/" element={r.element} />
) : (
<Route key={r.path} path={`/${r.path}`} element={r.element} />
)
)}
{/*
Non-default locales same routes nested under `/<locale>/`.
We register one branch per locale rather than a `:lang` param
so React Router doesn't accidentally swallow real top-level
paths like `/circuit-simulator` as a locale segment.
*/}
{NON_DEFAULT_LOCALES.map((locale) => (
<Route key={`locale-${locale}`} path={`/${locale}`}>
refactor(oss-split): remove auth/admin/profile frontend from OSS Phase 3 of the OSS / pro split — frontend side. Phase 2 already moved the auth/DB stack out of the OSS backend; this commit does the same for the React app. After this, the OSS image is editor + simulator + landing + docs only. What moved to the private overlay (pro/frontend/src/pro/): pages/{Login,Register,ForgotPassword,ResetPassword}Page.tsx pages/{Admin,UserProfile,Project,ProjectById}Page.tsx components/admin/{AdminBoardsTab,AdminDashboardTab,UserActivityModal}.tsx components/layout/{SaveProjectModal,LoginPromptModal}.tsx services/{authService,adminService}.ts store/useAuthStore.ts hooks/autoSaveImpl.ts New seams added so OSS components stay decoupled: * lib/proRoutes.ts — registerProRoutes()/useProRoutes() via useSyncExternalStore. mountPro() injects the moved pages at runtime; App.tsx subscribes to the registry, so registration after the initial render re-renders without a Not-Found flash. * lib/proSession.ts — registerSessionCheck()/triggerSessionCheck(). App.tsx fires this on mount instead of useAuthStore.checkSession(); pure OSS no-ops. * lib/proSaveAction.ts — installSaveActionImpl()/triggerSaveAction(). EditorPage's Save button dispatches through this; the overlay decides whether to show SaveProjectModal or LoginPromptModal based on auth state. In OSS without an overlay it's a no-op today; in Phase 4 of the split it becomes the .vlx Export entry point. OSS-side rewrites: * App.tsx drops the 8 page imports + 8 route entries; uses triggerSessionCheck() instead of useAuthStore directly. * AppHeader.tsx drops the user/login/register block entirely. The header-auth slot (introduced in Phase 1) now stays empty in OSS and gets filled by the overlay's portal mount. * EditorPage.tsx drops useAuthStore + SaveProjectModal + LoginPromptModal imports. The Save handler is now triggerSaveAction(). * LandingPage.tsx drops the dead UserMenu component (defined but never rendered) + its useAuthStore imports. * main.tsx drops the side-effect import of hooks/autoSaveImpl — the impl lives in pro now and self-registers via mountPro(). Build config: * vite.config.ts adds @velxio alias → src/. Lets the overlay import upstream modules (lib/proRoutes etc.) by stable name regardless of whether it's symlinked (local dev) or COPYed (Docker). * preserveSymlinks now gated on VITE_PRO_BUILD only (not on serve mode). Needed so Rollup keeps the overlay logically inside src/pro/ during local junction-based builds. Build verification: * OSS-only: 20-ish routes, no /login, /admin, /:username — 285 SEO pages prerendered. Bundle drops ~80-120 KB. * OSS + overlay: full 38 routes (30 upstream + 8 from registerProRoutes), HeaderAuth dropdown injected via slot, save action wired to the overlay's modal flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:31:12 +07:00
{allRoutes.map((r) =>
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
r.index ? (
<Route key={`${locale}-root`} index element={r.element} />
) : (
<Route
key={`${locale}-${r.path}`}
path={r.path}
element={r.element}
/>
)
)}
</Route>
))}
{/* `/en/...` is the default locale spelled out redirect to the
canonical prefix-free path instead of rendering a blank page. */}
<Route path="/en/*" element={<EnPrefixRedirect />} />
feat(i18n): react-i18next foundation + 9-locale support for header / footer This is Phase 1 of multi-language support: the visible chrome (header, footer, language switcher) and routing are wired up for all 9 locales (en, es, pt-br, it, fr, zh-cn, de, ja, ru) — same set the blog at velxio.dev/blog/ already supports. The Editor and the long-form landing-page copy are still English-only and will be translated in a follow-up. Infrastructure - frontend/src/i18n/config.ts: locale registry + LOCALE_META (htmlLang, native name, og locale, dir). Mirrors pro/blog/src/i18n/config.ts so cookie sync stays consistent. - frontend/src/i18n/cookie.ts: read/write the velxio_locale cookie at Path=/; Max-Age=1y; SameSite=Lax (Secure on HTTPS). The blog reads the same cookie via an inline script in its Layout.astro. - frontend/src/i18n/path.ts: getLocaleFromPath / stripLocaleFromPath / localizedPath / switchLocale / blogUrlFor — match the blog's helpers one-to-one. - frontend/src/i18n/index.ts: i18next bootstrap. English bundle is inlined synchronously for first paint; non-default locales are lazy-loaded via dynamic import on demand. Initial locale is decided in priority order URL > cookie > navigator > en. - frontend/src/i18n/LocaleSync.tsx: top-level wrapper inside <Router>. On every URL change loads the matching locale bundle, calls i18n.changeLanguage, writes the cookie, and mirrors the locale onto <html lang> and dir. - frontend/src/i18n/useLocalizedNavigate.ts: useCurrentLocale, useLocalizedHref, useLocalizedNavigate hooks for components that build internal links. Routing - App.tsx: route table extracted to a single ROUTES array, then registered twice — once at the root (default English) and once nested under each non-default locale (`/<locale>/...`). Explicit per-locale parent routes (rather than a generic `:lang` param) so React Router never accidentally swallows a real top-level path like `/circuit-simulator` as a locale segment. Header / Footer - LanguageSwitcher.tsx + .css: dropdown matching the blog's LanguageSwitcher.astro. Globe icon + locale code on the trigger, native names + ISO codes in the menu. Click → `switchLocale()` rewrites the URL under the new locale; LocaleSync handles the rest (load bundle, change language, write cookie). - AppHeader.tsx: every nav label and the auth dropdown copy now goes through `t('header.nav.*')`, `t('header.auth.*')`. All internal Links wrapped with localize() so navigation stays inside the active locale. Added a "Blog" link computed via `blogUrlFor(currentLocale)` so /es/ → /blog/es/, etc. - LandingPage.tsx: footer About-Velxio paragraph reads from t('footer.about'). Translations (Phase 1 strings) - frontend/src/i18n/locales/<locale>/common.json: nav labels, auth buttons, footer About copy. Hand-translated for all 9 locales, AGPLv3 / brand names preserved as-is. Tooling - frontend/scripts/translate-i18n.mjs: standalone Node script that takes the en.json bundles and auto-translates them to the 8 other locales via DeepSeek (primary) + Gemini (fallback). One LLM call per (locale, namespace) pair. Run after extracting new strings with `npm run translate:i18n`. Phase 2 (deferred) - Editor (toolbar, file explorer, simulator canvas, component picker, library manager, error toasts) — hundreds of strings. - Examples / Docs / About / Profile pages. - The translate-i18n.mjs script is ready to handle these once the strings have been extracted into JSON keys.
2026-05-09 10:40:37 +07:00
</Routes>
</LocaleSync>
</Router>
);
}
export default App;