Elffuss BraidHub

kikocis/VibeCodeViewer public

feat: add bilingual interface and docs
Changeset1f974bed798310bc46394f04f39f11131b044e0c805117acb5ace20d3f568c64
AuthorSendery <sendery@gmail.com> · 2026-06-23 15:46 +02:00
CommitterSendery <sendery@gmail.com> · 2026-06-23 15:46 +02:00
Parents9becfbfdcf77

Browse the files at this changeset

10 files changed

added README.en.md +296 −0
@@ -0,0 +1,296 @@
1+# VibeCodeViewer — Crystal Metropolis
2+
3+[Español](README.md) · **English**
4+
5+A procedural **glass-building city** (Three.js) that visualizes a code repository
6+as a sharp, nineties-hacker-style metropolis: cyan wireframes, a circuit-board
7+floor, local-first folder scanning, Git/ownership layers, blast-radius analysis,
8+and visual controls that increase drama without depending on HDR postprocessing.
9+
10+## Product presentation demo
11+
12+<p align="center">
13+ <a href="docs/assets/vibecodeviewer-hyperframes-presentation.web.mp4">
14+ <img src="docs/assets/vibecodeviewer-hyperframes-presentation-readme.gif" alt="VibeCodeViewer product presentation showing repository topology, navigation, search, Git, ownership, blast radius, themes and guided demo mode" width="900">
15+ </a>
16+</p>
17+
18+> GitHub README rendering is most reliable with animated GIF previews. Click the
19+> animation to open the optimized web MP4.
20+
21+- [Watch optimized web MP4](docs/assets/vibecodeviewer-hyperframes-presentation.web.mp4)
22+- [Open static poster](docs/assets/vibecodeviewer-hyperframes-presentation-poster.png)
23+
24+## Language support
25+
26+The application UI is available in **Spanish** and **English**.
27+
28+- Use the language selector in the left control stack.
29+- The choice is stored in `localStorage` under `vcc.language.v1`.
30+- You can force a language at startup with `?lang=es` or `?lang=en`.
31+- User-facing HUD text, search placeholders, settings, loading progress,
32+ disabled-mode tooltips, stats, Git labels, and Blast legends are translated.
33+
34+## Highlighted capabilities
35+
36+- **Repository-as-city topology:** folders become districts, nested modules become buildings, and files become luminous cells.
37+- **Spatial architecture review:** aerial, skyline, and guided camera views make hierarchy depth and dense areas readable at a glance.
38+- **File search and selection:** matching files pulse across the city; selecting a file lights its path through building and district.
39+- **Git status layer:** colors modified, new, renamed, and deleted files with repository-aware metadata.
40+- **Ownership layer:** visualizes CODEOWNERS and `metadata.owner` conventions as owner-specific color regions.
41+- **Blast radius analysis:** combines imports and symbol usage to show dependencies and downstream impact with animated beams.
42+- **Local-first scanning:** opens a folder directly in Chrome/Edge and rebuilds the city locally without regenerating checked-in data.
43+- **Ignored-code basements:** maps ignored files below the ground plane and can hide/reveal them with ground controls.
44+- **Themes and visual settings:** switches themes and tunes exposure, contrast, edges, labels, glass, fog, ground, and experimental bloom.
45+- **Guided demo mode:** chains topology, navigation, search, layers, themes, settings, legend, and final overview.
46+
47+## Repository → city mapping
48+
49+- Repository root → city.
50+- First-level folders → districts.
51+- Second-level folders → buildings.
52+- Very deep or dense subtrees → **developments** inside the district; their
53+ subfolders become buildings recursively.
54+- Interior nesting → floors → apartments → rooms → filing cabinets → drawers.
55+- Files → luminous cells at any level.
56+
57+Sizing rules:
58+
59+- Building width/depth is proportional to folder byte size using a logarithmic scale.
60+- Height is proportional to recursive file count.
61+- The file tree is printed onto the glass façade of each large building.
62+- Selecting a file highlights its path on the façade.
63+- Inside a drawer, files render as hanging vertical sheets; elsewhere they render as cube grids.
64+
65+## Hierarchical density lighting
66+
67+Selecting a file (click or search) lights its cell at full intensity and the
68+light decays level by level outward (`×0.56` per hop):
69+
70+```text
71+file ▓▓▓▓▓▓ → drawer ▓▓▓▓ → cabinet ▓▓▓ → room ▓▓ → floor ▓ → building ░ → district ·
72+```
73+
74+Lit interior levels receive a subtle volumetric fill. Buildings and districts
75+only light edges and fresnel so the interior remains readable.
76+
77+## Anti-blur recipe
78+
79+1. Thin edges in one `LineSegments` object, with color and opacity tunable from **Settings**.
80+2. Minimal-opacity **fresnel glass** (`α ≈ 0.02` in the face center).
81+3. No permanent additive volumes; fills exist only while a level is active.
82+4. Direct render by default. The old HDR/bloom composer remains experimental via `?bloom=1` because some drivers produce black screen-space rectangles while orbiting.
83+
84+## Extras
85+
86+- **Open Folder…** (Chrome/Edge): scans any local folder with the File System Access API and rebuilds the city live without regenerating `src/data.js`.
87+- **Basements:** files hidden by `.gitignore`, `.dockerignore`, or `.npmignore` are mapped below the circuit-board plane. The side tree shows them as `folder · basement`. Fully ignored folders become lower, more opaque bunker slabs.
88+- **Legend** (`L` or button): district names are silkscreened onto the floor like circuit traces, and folder names appear on building roofs.
89+- **District pulse:** the district containing the current selection remains slightly brighter and pulses softly.
90+- **Search suggestions:** matching files blink in the city and are highlighted on their buildings' façades as you type.
91+- **Settings:** modal panel under Reset View with visual presets and persistent sliders for exposure, brightness, contrast, saturation, edges, cells, glass, façades, labels, ground, and fog. Includes a **Bloom HDR** toggle that reloads with/without `?bloom=1`.
92+
93+## Coloring modes
94+
95+The top-center selector exposes **Basic · Git · Owners · Blast**. File color is
96+attenuated through the hierarchy: drawer, room, floor, building, and district.
97+
98+- **Basic:** the original cyan palette.
99+- **Git:** colors each file by Git status. The browser scanner parses `.git/index` directly for local folders; checked-in snapshots can also include `git status` and `git diff --numstat` metadata.
100+- **Owners:** parses `CODEOWNERS` and `package.yml` files with `metadata.owner`. Each owner gets a color and appears in a legend with file counts. See [Code Ownership reference](code_ownership_files.en.md).
101+- **Blast:** estimates the impact of a change in two layers:
102+ 1. Path imports (`src/codeLinks.js`) across JS/TS, C/C++, Python, CSS, HTML, and shell.
103+ 2. Symbol index (`src/codeIndex.js`) for JS/TS(X), Python, Ruby, C/C++, and Bash.
104+
105+When a file is selected in Blast mode:
106+
107+- Files that depend on it (downstream impact) light up with `beamIn`.
108+- Its dependencies light up with `beam`.
109+- Animated beams show propagation direction and the legend shows both counts.
110+
111+The analysis is cached with key `version|path|size|mtime`: Node uses
112+`.cache/analysis.json`; the browser uses IndexedDB. Re-scanning only reanalyzes
113+changed files.
114+
115+## Color themes
116+
117+The selector displays `Theme · …`. Full palettes live in `src/themes.js`; changing
118+theme rebuilds only the city while keeping the model, camera, and selection.
119+
120+- **Hacker** — original cyan/purple on black.
121+- **Factorial** — dark corporate palette with dominant red `#E51943` and structural green `#007C85`; UI panels are light (`uiLight`).
122+- **Synthwave** — magenta and sunset orange on deep purple.
123+- **Matrix** — monochrome green phosphor on black.
124+- **Glaciar** — ice blues and cool whites on navy.
125+
126+The **Opaque Ground** button (`G`) hides basements by writing depth; translucent
127+ground lets you glimpse them.
128+
129+## Visual settings and bloom
130+
131+The **Settings** button opens four presets:
132+
133+- **Safe:** base values, direct render.
134+- **Neon:** more saturation and brightness without using bloom.
135+- **Cinema:** more contrast, denser fog, less dominant ground.
136+- **Intense:** more exposure and stronger edges/cells; the most aggressive tested preset without black artifacts.
137+
138+Sliders apply live and persist in `localStorage` under `vcc.visualSettings.v1`.
139+The HUD shows whether you are using direct render or `bloom ×N`.
140+
141+`?bloom=1` enables `EffectComposer` + `UnrealBloomPass`. It is kept for
142+experimentation but is not the default because some GPU/driver combinations show
143+black rectangles during orbit. Remove `bloom` from the URL or uncheck **Bloom HDR**
144+to return to stable mode.
145+
146+## GPU diagnostics
147+
148+Detection uses the real WebGL renderer exposed by the browser
149+(`WEBGL_debug_renderer_info` when available). On Windows/WSLg or virtualized
150+layers it may show `D3D12 virtual`, `Mesa`, or `Microsoft` even when the host has
151+an NVIDIA GPU. In that case the app treats it as hardware accelerated but cannot
152+invent the hidden brand.
153+
154+Useful debug overrides:
155+
156+- `?gpu=nvidia` forces the NVIDIA label/profile when the host has NVIDIA but the browser reports a virtual layer.
157+- `?msaa=N` and `?pr=N` force render-target multisampling and pixel ratio.
158+- `?bloom=1` enables the experimental HDR composer.
159+
160+## Keyboard in the tree
161+
162+With the tree focused:
163+
164+- `↑` / `↓`: move cursor.
165+- `→`: expand a folder or enter it.
166+- `←`: collapse or jump to parent.
167+- `PageDown` / `PageUp`: move one page.
168+- `Enter` / `Space`: select the item and fly the camera to it.
169+
170+## Large monorepos
171+
172+Tested with a real monorepo of about 120k files and 42 first-level districts.
173+
174+- **Developments:** towers absorb up to 5 levels of interior nesting. Deeper or very dense subtrees become developments so the city spreads instead of compressing into one tower.
175+- Large cities apply a smooth, uniform attenuation to edges, glass, and cells while keeping district and development perimeters bright.
176+- The tree scan is complete and has no file-count limit.
177+- Blast reads file contents only within a budget (20k files / 48 MB), ordered by priority, in resumable batches.
178+- Edge LOD draws only the most relevant boxes; brightness is normalized per building.
179+- Text façades are limited to the 250 largest buildings; roof labels to 400; slabs to 4000 floors.
180+- The side tree is lazy: branches mount in the DOM only when expanded.
181+- `node_modules` and `.git/objects` are always skipped.
182+
183+## Run
184+
185+A static server is required because ES modules and import maps do not work from
186+`file://`:
187+
188+```bash
189+./serve.sh # serves on all network interfaces and lists URLs
190+./serve.sh 9000 # alternate port
191+# or manually: python3 -m http.server 8137 --bind 0.0.0.0
192+```
193+
194+The File System Access API (**Open Folder…**) requires a secure context. From
195+another machine on the network use HTTPS or a tunnel; `http://localhost` works.
196+
197+No build step is required: Three.js r160 is vendored in `vendor/` for offline use.
198+
199+Regenerate the repository snapshot (`src/data.js`):
200+
201+```bash
202+node scan.mjs # scans the parent folder
203+node scan.mjs /other/path # scans another tree
204+```
205+
206+## Automated visual verification
207+
208+Use these tools to record orbits and detect black-frame regressions:
209+
210+```bash
211+# 1. Start the app and a Chromium instance with remote DevTools.
212+./serve.sh 8137
213+chromium-browser --headless --disable-gpu-sandbox --no-sandbox \
214+ --remote-debugging-port=9223 --window-size=2048,1152 about:blank
215+
216+# 2. Capture an orbit with a theme/preset.
217+node tools/capture-orbit.mjs \
218+ --url=http://localhost:8137/ \
219+ --out=/tmp/vcc-orbit \
220+ --frames=120 --width=2048 --height=1152 --port=9223 --theme=matrix \
221+ --visuals='{"exposure":1.24,"brightness":1.08,"contrast":1.28,"saturate":1.65,"lines":1.22,"files":1.35,"glass":1.16,"facades":1.12,"labels":1.45,"ground":1.08,"fog":0.92}'
222+
223+# 3. Optionally generate a video.
224+ffmpeg -y -framerate 30 -i /tmp/vcc-orbit/frame-%04d.png \
225+ -pix_fmt yuv420p /tmp/vcc-orbit.mp4
226+
227+# 4. Detect black rectangles in an orbit.
228+python3 tools/detect-black-rects.py /tmp/vcc-orbit
229+
230+# 5. Detect the case of one screenshot, more sensitive to black windows.
231+python3 tools/detect-black-rects.py --scan-windows screenshot.png
232+
233+# 6. Compare a candidate against a stable baseline.
234+python3 tools/compare-black-regressions.py /tmp/candidate /tmp/baseline
235+```
236+
237+`tools/detect-black-rects.py` uses Pillow/NumPy instead of OpenCV to avoid new
238+dependencies. It exits with code 1 when bad frames are found.
239+
240+## Test mode: `./serve.sh --test N M [K]`
241+
242+Generates deterministic synthetic `src/data.js` via `tools/gentest.mjs` for
243+rendering tests with controlled geometry.
244+
245+- **Without K:** N independent chains; each file lives at the bottom of M nested folders.
246+- **With K (development mode):** N files are grouped; each district contains an `urb_g` block with K development-level folders, each continuing to total depth M.
247+
248+Examples:
249+
250+```bash
251+./serve.sh --test 2 3
252+./serve.sh --test 500 8
253+./serve.sh --test 1000 8 250
254+./serve.sh --test 1000 4 250
255+./serve.sh --test 2500 3 2500
256+./serve.sh --test 9000 9 300
257+./serve.sh 8200 --test 100 10
258+```
259+
260+Restore the real snapshot with `git checkout -- src/data.js` or rerun `scan.mjs`.
261+`./serve.sh --help` prints a summary.
262+
263+## Controls
264+
265+- Drag / wheel: orbit · zoom.
266+- Click: select file or building; empty click clears selection.
267+- Hover: highlights building under cursor.
268+- `F`: **fly mode** with pointer lock; crosses walls.
269+- `W A S D` / mouse: move · look in fly mode.
270+- `Space` / `E` · `C` / `Q`: up · down · `Shift` turbo.
271+- `1` `2` `3`: Reset View · Aerial View · Building Height View.
272+- `L` · `G`: legend · opaque ground.
273+- `X` · `/`: clear selection · focus search.
274+- `Esc`: exit fly mode / close search / close Settings.
275+
276+## Structure
277+
278+```text
279+index.html HTML shell + importmap
280+scan.mjs repository scanner → src/data.js
281+README.md Spanish documentation
282+README.en.md English documentation
283+src/
284+ data.js tree snapshot (generated)
285+ i18n.js Spanish/English UI strings and language persistence
286+ model.js hierarchy + layout (nested boxes, urban packing)
287+ builder.js scene: HDR edges, fresnel glass, façades, PCB ground
288+ controls.js orbit + free flight + camera flights
289+ ui.js side tree, search, path, stats, Settings, language selector
290+ main.js hierarchical selection, raycast, render, visual settings
291+tools/
292+ capture-orbit.mjs captures orbits via Chrome DevTools Protocol
293+ detect-black-rects.py detects black rectangles in frames/screenshots
294+ compare-black-regressions.py compares orbits against a visual baseline
295+vendor/ Three.js r160 + addons (offline)
296+```
modified README.md +25 −18
@@ -1,36 +1,38 @@
11 # VibeCodeViewer — Metrópolis de Cristal
22
3+**Español** · [English](README.en.md)
4+
35 Ciudad procedural de **edificios de cristal** (Three.js) que visualiza un
46 repositorio de código como una metrópolis estilo *hacker noventero*: wireframes
57 cian nítidos, suelo de placa de circuito impreso y controles visuales para
68 subir el dramatismo sin depender del postprocesado HDR.
79
8-## Product presentation demo
10+## Demo de presentación del producto
911
1012 <p align="center">
1113 <a href="docs/assets/vibecodeviewer-hyperframes-presentation.web.mp4">
12- <img src="docs/assets/vibecodeviewer-hyperframes-presentation-readme.gif" alt="VibeCodeViewer product presentation showing repository topology, navigation, search, Git, ownership, blast radius, themes and guided demo mode" width="900">
14+ <img src="docs/assets/vibecodeviewer-hyperframes-presentation-readme.gif" alt="Presentación de producto de VibeCodeViewer mostrando topología del repositorio, navegación, búsqueda, Git, ownership, radio de impacto, temas y modo demo guiado" width="900">
1315 </a>
1416 </p>
1517
16-> GitHub README rendering is most reliable with animated GIF previews. Click the
17-> animation to open the optimized web MP4.
18+> El renderizado del README de GitHub es más fiable con previsualizaciones GIF
19+> animadas. Haz clic en la animación para abrir el MP4 web optimizado.
1820
19-- [Watch optimized web MP4](docs/assets/vibecodeviewer-hyperframes-presentation.web.mp4)
20-- [Open static poster](docs/assets/vibecodeviewer-hyperframes-presentation-poster.png)
21+- [Ver MP4 web optimizado](docs/assets/vibecodeviewer-hyperframes-presentation.web.mp4)
22+- [Abrir póster estático](docs/assets/vibecodeviewer-hyperframes-presentation-poster.png)
2123
22-### Highlighted capabilities
24+### Funcionalidades destacadas
2325
24-- **Repository-as-city topology:** maps folders to districts, nested modules to buildings, and files to luminous cells.
25-- **Spatial architecture review:** aerial, skyline, and guided camera views make hierarchy depth and dense areas readable at a glance.
26-- **File search and selection:** matching files pulse across the city, while a selected file lights its complete path through building and district.
27-- **Git status layer:** colors modified, new, renamed, and changed files with repository-aware metadata.
28-- **Ownership layer:** visualizes CODEOWNERS and `metadata.owner` conventions as owner-specific color regions.
29-- **Blast radius analysis:** combines imports and symbol usage to show dependencies and downstream impact with animated beams.
30-- **Local-first scanning:** opens a folder directly in Chrome/Edge and rebuilds the city locally without regenerating checked-in data.
31-- **Ignored-code basements:** maps ignored files below the ground plane and can hide/reveal them with ground controls.
32-- **Themes and visual settings:** switches themes and tunes exposure, contrast, edges, labels, glass, fog, ground, and experimental bloom.
33-- **Guided demo mode:** automatically chains topology, navigation, search, layers, themes, settings, legend, and final overview.
26+- **Topología repositorio-como-ciudad:** carpetas como distritos, módulos anidados como edificios y ficheros como celdas luminosas.
27+- **Revisión espacial de arquitectura:** vistas aérea, skyline y cámara guiada para entender profundidad jerárquica y zonas densas de un vistazo.
28+- **Búsqueda y selección de ficheros:** los ficheros coincidentes laten en la ciudad y el seleccionado ilumina toda su ruta por edificio y distrito.
29+- **Capa de estado Git:** colorea ficheros modificados, nuevos, renombrados y borrados con metadatos del repositorio.
30+- **Capa de ownership:** visualiza CODEOWNERS y convenciones `metadata.owner` como regiones de color por propietario.
31+- **Análisis de radio de impacto:** combina imports y uso de símbolos para mostrar dependencias e impacto descendente con haces animados.
32+- **Escaneo local-first:** abre una carpeta directamente en Chrome/Edge y reconstruye la ciudad localmente sin regenerar datos versionados.
33+- **Sótanos de código ignorado:** sitúa ficheros ignorados bajo el plano del suelo y permite ocultarlos/mostrarlos con los controles de suelo.
34+- **Temas y ajustes visuales:** cambia temas y ajusta exposición, contraste, aristas, rótulos, cristal, niebla, suelo y bloom experimental.
35+- **Modo demo guiado:** encadena topología, navegación, búsqueda, capas, temas, settings, leyenda y vista final.
3436
3537 ## Mapeo repo → ciudad
3638
@@ -76,6 +78,10 @@
7678
7779 ## Extras
7880
81+- **Idioma / Language**: el selector de idioma de la columna izquierda cambia
82+ toda la interfaz entre **español** e **inglés**. La preferencia se guarda en
83+ `localStorage` (`vcc.language.v1`) y también se puede fijar con `?lang=es` o
84+ `?lang=en`.
7985 - **Abrir Carpeta…** (Chrome/Edge): escanea cualquier carpeta local con la
8086 File System Access API y reconstruye la ciudad al vuelo, sin regenerar
8187 `src/data.js`.
@@ -83,7 +89,7 @@
8389 `.npmignore` se mapean bajo el plano de circuitos, con el mismo patrón de
8490 segmentación pero creciendo hacia abajo (el suelo es semitransparente y en
8591 modo vuelo puedes bajar a recorrerlos). En el árbol lateral aparecen en
86- ámbar como `carpeta · sótano`. Si una carpeta no tiene **nada** en
92+ ámbar como `carpeta · sótano` en español o `folder · basement` en inglés. Si una carpeta no tiene **nada** en
8793 superficie (todo su contenido está ignorado), en vez de torre se dibuja un
8894 **búnker**: una losa baja y más opaca que señala que la información está
8995 bajo el suelo.
@@ -384,6 +390,7 @@
384390 scan.mjs escáner del repo → src/data.js
385391 src/
386392 data.js snapshot del árbol (generado)
393+ i18n.js textos de UI español/inglés y persistencia de idioma
387394 model.js jerarquía + layout (cajas anidadas, empaquetado urbano)
388395 builder.js escena: aristas HDR, cristal fresnel, fachadas, suelo PCB
389396 controls.js órbita + vuelo libre + vuelos de cámara
added code_ownership_files.en.md +52 −0
@@ -0,0 +1,52 @@
1+# Code Ownership — Reference
2+
3+[Español](code_ownership_files.md) · **English**
4+
5+VibeCodeViewer can visualize repository ownership in **Owners** mode by parsing
6+two sources.
7+
8+## 1. CODEOWNERS
9+
10+The standard GitHub/GitLab file. Each line maps a path pattern to one or more
11+owners:
12+
13+```text
14+/src/ @org/frontend-team
15+/backend/ @org/backend-team
16+*.md @org/docs
17+```
18+
19+The last matching rule wins, following GitHub semantics. VibeCodeViewer parses
20+this in `src/ownership.js`.
21+
22+## 2. `package.yml` with `metadata.owner`
23+
24+A common monorepo convention: each component declares its owner in a
25+`package.yml` file:
26+
27+```yaml
28+metadata:
29+ domain: YourDomain
30+ owner: '@org/your_team'
31+ reviewers: []
32+```
33+
34+VibeCodeViewer scans all `package.yml` files in the tree and extracts
35+`metadata.owner` as the owner of the folder that contains it.
36+
37+## Query ownership
38+
39+```bash
40+# Owner of a file according to CODEOWNERS
41+git check-attr CODEOWNERS path/to/your/file.rb
42+
43+# List files for a team
44+grep "@org/team-name" CODEOWNERS | awk '{print $1}'
45+```
46+
47+## Visualization
48+
49+In **Owners** mode, each owner receives a color (hues distributed with the
50+golden angle) and appears in a legend above the navigation panel with its file
51+count. The color is attenuated through the full hierarchy: drawer, room, floor,
52+building, and district are tinted according to the files they contain.
modified code_ownership_files.md +2 −0
@@ -1,5 +1,7 @@
11 # Code Ownership — Referencia
22
3+**Español** · [English](code_ownership_files.en.md)
4+
35 VibeCodeViewer puede visualizar el ownership de un repositorio (modo **Owners**)
46 parseando dos fuentes:
57
modified index.html +33 −29
@@ -20,33 +20,37 @@
2020 <div id="stats"></div>
2121
2222 <div id="mode-switch">
23- <button data-mode="basic" class="active">Básico</button>
24- <button data-mode="git">Git</button>
25- <button data-mode="ownership">Owners</button>
26- <button data-mode="blast">Blast</button>
23+ <button data-mode="basic" class="active" data-i18n="mode.basic">Básico</button>
24+ <button data-mode="git" data-i18n="mode.git">Git</button>
25+ <button data-mode="ownership" data-i18n="mode.ownership">Owners</button>
26+ <button data-mode="blast" data-i18n="mode.blast">Blast</button>
2727 </div>
2828
2929
3030 <div id="view-buttons">
31- <button id="btn-aerial">Vista Aérea</button>
32- <button id="btn-skyline">Vista Altura Edificios</button>
33- <button id="btn-reset">Reset Vista</button>
34- <button id="btn-settings" onclick="window.VCCOpenSettings?.()">Settings</button>
35- <button id="btn-legend">Leyenda</button>
36- <button id="btn-ground">Suelo Opaco</button>
37- <select id="theme-select" title="Tema de color"></select>
31+ <select id="lang-select" title="Idioma" data-i18n-title="label.language">
32+ <option value="es">Español</option>
33+ <option value="en">English</option>
34+ </select>
35+ <button id="btn-aerial" data-i18n="button.aerial">Vista Aérea</button>
36+ <button id="btn-skyline" data-i18n="button.skyline">Vista Altura Edificios</button>
37+ <button id="btn-reset" data-i18n="button.resetView">Reset Vista</button>
38+ <button id="btn-settings" onclick="window.VCCOpenSettings?.()" data-i18n="button.settings">Settings</button>
39+ <button id="btn-legend" data-i18n="button.legend">Leyenda</button>
40+ <button id="btn-ground" data-i18n="button.ground">Suelo Opaco</button>
41+ <select id="theme-select" title="Tema de color" data-i18n-title="label.themeTitle"></select>
3842 <button id="btn-reopen" style="display:none"></button>
39- <button id="btn-folder">Abrir Carpeta…</button>
43+ <button id="btn-folder" data-i18n="button.openFolder">Abrir Carpeta…</button>
4044 </div>
4145
4246 <div id="search-panel">
43- <div class="title">Búsqueda</div>
44- <input id="search-input" type="text" placeholder="Buscar fichero… (p. ej. *.js, src/*.css)" autocomplete="off" spellcheck="false">
47+ <div class="title" data-i18n="search.title">Búsqueda</div>
48+ <input id="search-input" type="text" placeholder="Buscar fichero… (p. ej. *.js, src/*.css)" data-i18n-placeholder="search.placeholder" autocomplete="off" spellcheck="false">
4549 <div id="search-results"></div>
4650 </div>
4751
4852 <div id="tree-panel">
49- <div class="title">Árbol de ficheros</div>
53+ <div class="title" data-i18n="tree.title">Árbol de ficheros</div>
5054 <div id="tree"></div>
5155 </div>
5256
@@ -55,17 +59,17 @@
5559 <div id="right-stack">
5660 <div id="color-legend"></div>
5761 <div id="help">
58- <div class="title">Navegación</div>
62+ <div class="title" data-i18n="help.title">Navegación</div>
5963 <table>
60- <tr><td>Arrastrar</td><td>orbitar · rueda zoom</td></tr>
61- <tr><td>Clic</td><td>seleccionar fichero / edificio</td></tr>
62- <tr><td><b>F</b></td><td>modo vuelo (atraviesa paredes)</td></tr>
63- <tr><td>W A S D</td><td>mover · ratón mirar</td></tr>
64- <tr><td>Space / C</td><td>subir / bajar · <b>Shift</b> turbo</td></tr>
65- <tr><td>1 · 2 · 3</td><td>reset · aérea · altura</td></tr>
66- <tr><td><b>X</b></td><td>limpiar selección · <b>/</b> buscar</td></tr>
67- <tr><td><b>L</b> · <b>G</b></td><td>leyenda · suelo opaco</td></tr>
68- <tr><td>↑↓ ←→</td><td>navegar árbol · plegar/desplegar</td></tr>
64+ <tr><td data-i18n="help.drag.key">Arrastrar</td><td data-i18n="help.drag.value">orbitar · rueda zoom</td></tr>
65+ <tr><td data-i18n="help.click.key">Clic</td><td data-i18n="help.click.value">seleccionar fichero / edificio</td></tr>
66+ <tr><td><b data-i18n="help.fly.key">F</b></td><td data-i18n="help.fly.value">modo vuelo (atraviesa paredes)</td></tr>
67+ <tr><td data-i18n="help.move.key">W A S D</td><td data-i18n="help.move.value">mover · ratón mirar</td></tr>
68+ <tr><td data-i18n="help.vertical.key">Space / C</td><td data-i18n="help.vertical.value">subir / bajar · Shift turbo</td></tr>
69+ <tr><td data-i18n="help.views.key">1 · 2 · 3</td><td data-i18n="help.views.value">reset · aérea · altura</td></tr>
70+ <tr><td><b data-i18n="help.clear.key">X</b></td><td data-i18n="help.clear.value">limpiar selección · / buscar</td></tr>
71+ <tr><td><b data-i18n="help.toggles.key">L · G</b></td><td data-i18n="help.toggles.value">leyenda · suelo opaco</td></tr>
72+ <tr><td data-i18n="help.tree.key">↑↓ ←→</td><td data-i18n="help.tree.value">navegar árbol · plegar/desplegar</td></tr>
6973 </table>
7074 </div>
7175 </div>
@@ -75,14 +79,14 @@
7579 <div id="settings-modal" aria-hidden="true">
7680 <div id="settings-panel" role="dialog" aria-modal="true" aria-labelledby="settings-title">
7781 <div class="settings-head">
78- <div id="settings-title" class="title">Settings</div>
79- <button id="settings-close" title="Cerrar" onclick="window.VCCCloseSettings?.()">×</button>
82+ <div id="settings-title" class="title" data-i18n="settings.title">Settings</div>
83+ <button id="settings-close" title="Cerrar" data-i18n-title="settings.close" onclick="window.VCCCloseSettings?.()">×</button>
8084 </div>
8185 <div id="settings-presets"></div>
8286 <div id="settings-controls"></div>
8387 <div class="settings-foot">
84- <label class="check-row"><input id="setting-bloom" type="checkbox"> Bloom HDR</label>
85- <button id="settings-reset">Reset Settings</button>
88+ <label class="check-row"><input id="setting-bloom" type="checkbox"> <span data-i18n="settings.bloom">Bloom HDR</span></label>
89+ <button id="settings-reset" data-i18n="button.resetSettings">Reset Settings</button>
8690 </div>
8791 </div>
8892 </div>
modified src/colorModes.js +2 −1
@@ -2,6 +2,7 @@
22 // git) y ownership (un color por code owner). El color del fichero se
33 // propaga atenuado a sus contenedores: habitación, planta, edificio, barrio…
44 // Los colores base por rol salen del tema activo.
5+import { t } from './i18n.js';
56
67 export const GIT_STATUS = {
78 M: { label: 'Modificado', color: [0.95, 0.65, 0.10] },
@@ -79,7 +80,7 @@
7980 const base = ROLE_COLOR[node.role] ?? ROLE_COLOR.cajon;
8081 return lerp3(base, t.color.map(c => c * 0.55), 0.25 + 0.55 * t.frac);
8182 },
82- legend: [...present].map(st => ({ label: GIT_STATUS[st].label, color: gitColor(st) })),
83+ legend: [...present].map(st => ({ label: t(`gitStatus.${st}`), color: gitColor(st) })),
8384 };
8485 }
8586 if (mode === 'ownership' && model.owners.length) {
modified src/fsScan.js +3 −2
@@ -18,6 +18,7 @@
1818 loadSavedHandle, saveHandle,
1919 } from './analysisCache.js';
2020 import { priorityScore } from './filePriority.js';
21+import { t } from './i18n.js';
2122
2223 const SKIP = new Set(['node_modules', '.DS_Store']);
2324 // presupuesto del análisis de código (modo Blast): solo la lectura de
@@ -154,7 +155,7 @@
154155 outFiles.push(ign ? [f.name, size, 1] : [f.name, size]);
155156 fileRels.push(childRel);
156157 count++;
157- if (count % 200 === 0) onProgress?.(`${count} ficheros`);
158+ if (count % 200 === 0) onProgress?.(t('progress.files', { count }));
158159 if (!file || childRel.startsWith('.git/')) continue;
159160 // estado git aproximado (limpio → sin entrada)
160161 if (gitMap && !ign) {
@@ -226,7 +227,7 @@
226227 pendingUsed = {};
227228 batchBytes = 0;
228229 checkpoints++;
229- onTick?.(`análisis ${analyzed}/${total} · checkpoint ${checkpoints}`);
230+ onTick?.(t('progress.analysisCheckpoint', { analyzed, total, checkpoints }));
230231 }
231232
232233 for (const c of candidates) {
added src/i18n.js +227 −0
@@ -0,0 +1,227 @@
1+const STORAGE_KEY = 'vcc.language.v1';
2+
3+export const LANGUAGES = {
4+ es: 'Español',
5+ en: 'English',
6+};
7+
8+const STRINGS = {
9+ es: {
10+ 'app.title': 'VibeCodeViewer — Metrópolis de Cristal',
11+ 'mode.basic': 'Básico',
12+ 'mode.git': 'Git',
13+ 'mode.ownership': 'Owners',
14+ 'mode.blast': 'Blast',
15+ 'button.aerial': 'Vista Aérea',
16+ 'button.skyline': 'Vista Altura Edificios',
17+ 'button.resetView': 'Reset Vista',
18+ 'button.settings': 'Settings',
19+ 'button.legend': 'Leyenda',
20+ 'button.ground': 'Suelo Opaco',
21+ 'button.openFolder': 'Abrir Carpeta…',
22+ 'button.reopen': 'Reabrir {name}',
23+ 'button.resetSettings': 'Reset Settings',
24+ 'label.language': 'Idioma',
25+ 'label.themeTitle': 'Tema de color',
26+ 'search.title': 'Búsqueda',
27+ 'search.placeholder': 'Buscar fichero… (p. ej. *.js, src/*.css)',
28+ 'tree.title': 'Árbol de ficheros',
29+ 'help.title': 'Navegación',
30+ 'help.drag.key': 'Arrastrar',
31+ 'help.drag.value': 'orbitar · rueda zoom',
32+ 'help.click.key': 'Clic',
33+ 'help.click.value': 'seleccionar fichero / edificio',
34+ 'help.fly.key': 'F',
35+ 'help.fly.value': 'modo vuelo (atraviesa paredes)',
36+ 'help.move.key': 'W A S D',
37+ 'help.move.value': 'mover · ratón mirar',
38+ 'help.vertical.key': 'Space / C',
39+ 'help.vertical.value': 'subir / bajar · Shift turbo',
40+ 'help.views.key': '1 · 2 · 3',
41+ 'help.views.value': 'reset · aérea · altura',
42+ 'help.clear.key': 'X',
43+ 'help.clear.value': 'limpiar selección · / buscar',
44+ 'help.toggles.key': 'L · G',
45+ 'help.toggles.value': 'leyenda · suelo opaco',
46+ 'help.tree.key': '↑↓ ←→',
47+ 'help.tree.value': 'navegar árbol · plegar/desplegar',
48+ 'settings.title': 'Settings',
49+ 'settings.close': 'Cerrar',
50+ 'settings.bloom': 'Bloom HDR',
51+ 'settings.exposure': 'Exposición',
52+ 'settings.brightness': 'Brillo',
53+ 'settings.contrast': 'Contraste',
54+ 'settings.saturate': 'Saturación',
55+ 'settings.lines': 'Aristas',
56+ 'settings.files': 'Celdas',
57+ 'settings.glass': 'Cristal',
58+ 'settings.facades': 'Fachadas',
59+ 'settings.labels': 'Rótulos',
60+ 'settings.ground': 'Suelo',
61+ 'settings.fog': 'Niebla',
62+ 'preset.safe': 'Seguro',
63+ 'preset.neon': 'Neón',
64+ 'preset.cinema': 'Cine',
65+ 'preset.intense': 'Intenso',
66+ 'theme.prefix': 'Tema · {label}',
67+ 'path.none': '— sin selección · clic en un edificio o busca un fichero —',
68+ 'tree.basementSuffix': 'sótano',
69+ 'modeUnavailable.git': 'sin datos git (ni .git/index legible)',
70+ 'modeUnavailable.ownership': 'sin reglas de code ownership',
71+ 'modeUnavailable.blast': 'sin relaciones de código detectadas',
72+ 'stats.urbs': ' · {count} urbanizaciones',
73+ 'stats.main': '{base} ficheros + {ignored} ignorados · {buildings} edificios{urbs} · {districts} distritos · {fps} fps{gpu}{analysis}',
74+ 'gpu.direct': 'render directo',
75+ 'gpu.software': ' · render software · {mode}',
76+ 'gpu.high': ' · GPU {brand} · {mode}',
77+ 'gpu.other': ' · {mode}',
78+ 'gpu.discrete': 'discreta',
79+ 'analysis.loading': 'Escaneando…',
80+ 'analysis.loadingDetail': 'Escaneando… {msg}',
81+ 'progress.files': '{count} ficheros',
82+ 'progress.analysisCheckpoint': 'análisis {analyzed}/{total} · checkpoint {checkpoints}',
83+ 'legend.impact': 'Impacto: dependen de él',
84+ 'legend.dependencies': 'Dependencias: usa de ellos',
85+ 'gitStatus.M': 'Modificado',
86+ 'gitStatus.A': 'Añadido (staged)',
87+ 'gitStatus.U': 'Sin seguimiento',
88+ 'gitStatus.R': 'Renombrado',
89+ 'gitStatus.D': 'Borrado',
90+ },
91+ en: {
92+ 'app.title': 'VibeCodeViewer — Crystal Metropolis',
93+ 'mode.basic': 'Basic',
94+ 'mode.git': 'Git',
95+ 'mode.ownership': 'Owners',
96+ 'mode.blast': 'Blast',
97+ 'button.aerial': 'Aerial View',
98+ 'button.skyline': 'Building Height View',
99+ 'button.resetView': 'Reset View',
100+ 'button.settings': 'Settings',
101+ 'button.legend': 'Legend',
102+ 'button.ground': 'Opaque Ground',
103+ 'button.openFolder': 'Open Folder…',
104+ 'button.reopen': 'Reopen {name}',
105+ 'button.resetSettings': 'Reset Settings',
106+ 'label.language': 'Language',
107+ 'label.themeTitle': 'Color theme',
108+ 'search.title': 'Search',
109+ 'search.placeholder': 'Search file… (e.g. *.js, src/*.css)',
110+ 'tree.title': 'File tree',
111+ 'help.title': 'Navigation',
112+ 'help.drag.key': 'Drag',
113+ 'help.drag.value': 'orbit · wheel zoom',
114+ 'help.click.key': 'Click',
115+ 'help.click.value': 'select file / building',
116+ 'help.fly.key': 'F',
117+ 'help.fly.value': 'fly mode (crosses walls)',
118+ 'help.move.key': 'W A S D',
119+ 'help.move.value': 'move · mouse look',
120+ 'help.vertical.key': 'Space / C',
121+ 'help.vertical.value': 'up / down · Shift turbo',
122+ 'help.views.key': '1 · 2 · 3',
123+ 'help.views.value': 'reset · aerial · height',
124+ 'help.clear.key': 'X',
125+ 'help.clear.value': 'clear selection · / search',
126+ 'help.toggles.key': 'L · G',
127+ 'help.toggles.value': 'legend · opaque ground',
128+ 'help.tree.key': '↑↓ ←→',
129+ 'help.tree.value': 'navigate tree · collapse/expand',
130+ 'settings.title': 'Settings',
131+ 'settings.close': 'Close',
132+ 'settings.bloom': 'Bloom HDR',
133+ 'settings.exposure': 'Exposure',
134+ 'settings.brightness': 'Brightness',
135+ 'settings.contrast': 'Contrast',
136+ 'settings.saturate': 'Saturation',
137+ 'settings.lines': 'Edges',
138+ 'settings.files': 'Cells',
139+ 'settings.glass': 'Glass',
140+ 'settings.facades': 'Facades',
141+ 'settings.labels': 'Labels',
142+ 'settings.ground': 'Ground',
143+ 'settings.fog': 'Fog',
144+ 'preset.safe': 'Safe',
145+ 'preset.neon': 'Neon',
146+ 'preset.cinema': 'Cinema',
147+ 'preset.intense': 'Intense',
148+ 'theme.prefix': 'Theme · {label}',
149+ 'path.none': '— no selection · click a building or search for a file —',
150+ 'tree.basementSuffix': 'basement',
151+ 'modeUnavailable.git': 'no git data (no readable .git/index)',
152+ 'modeUnavailable.ownership': 'no code ownership rules',
153+ 'modeUnavailable.blast': 'no code relationships detected',
154+ 'stats.urbs': ' · {count} developments',
155+ 'stats.main': '{base} files + {ignored} ignored · {buildings} buildings{urbs} · {districts} districts · {fps} fps{gpu}{analysis}',
156+ 'gpu.direct': 'direct render',
157+ 'gpu.software': ' · software render · {mode}',
158+ 'gpu.high': ' · GPU {brand} · {mode}',
159+ 'gpu.other': ' · {mode}',
160+ 'gpu.discrete': 'discrete',
161+ 'analysis.loading': 'Scanning…',
162+ 'analysis.loadingDetail': 'Scanning… {msg}',
163+ 'progress.files': '{count} files',
164+ 'progress.analysisCheckpoint': 'analysis {analyzed}/{total} · checkpoint {checkpoints}',
165+ 'legend.impact': 'Impact: depend on it',
166+ 'legend.dependencies': 'Dependencies: used by it',
167+ 'gitStatus.M': 'Modified',
168+ 'gitStatus.A': 'Added (staged)',
169+ 'gitStatus.U': 'Untracked',
170+ 'gitStatus.R': 'Renamed',
171+ 'gitStatus.D': 'Deleted',
172+ },
173+};
174+
175+function normalizeLang(value) {
176+ const raw = String(value || '').toLowerCase();
177+ if (raw.startsWith('es')) return 'es';
178+ if (raw.startsWith('en')) return 'en';
179+ return null;
180+}
181+
182+function initialLanguage() {
183+ const url = normalizeLang(new URLSearchParams(location.search).get('lang'));
184+ if (url) return url;
185+ const stored = normalizeLang(localStorage.getItem(STORAGE_KEY));
186+ if (stored) return stored;
187+ return normalizeLang(navigator.language) || 'es';
188+}
189+
190+let currentLanguage = initialLanguage();
191+const listeners = new Set();
192+
193+document.documentElement.lang = currentLanguage;
194+
195+export function language() {
196+ return currentLanguage;
197+}
198+
199+export function t(key, params = {}) {
200+ const table = STRINGS[currentLanguage] ?? STRINGS.es;
201+ const fallback = STRINGS.es[key] ?? key;
202+ const template = table[key] ?? fallback;
203+ return String(template).replace(/\{(\w+)\}/g, (_, name) => params[name] ?? '');
204+}
205+
206+export function setLanguage(next) {
207+ const normalized = normalizeLang(next) || 'es';
208+ if (normalized === currentLanguage) return currentLanguage;
209+ currentLanguage = normalized;
210+ localStorage.setItem(STORAGE_KEY, normalized);
211+ document.documentElement.lang = normalized;
212+ for (const fn of listeners) fn(normalized);
213+ return currentLanguage;
214+}
215+
216+export function onLanguageChange(fn) {
217+ listeners.add(fn);
218+ return () => listeners.delete(fn);
219+}
220+
221+export function applyDocumentTranslations(root = document) {
222+ document.title = t('app.title');
223+ root.querySelectorAll('[data-i18n]').forEach((el) => { el.textContent = t(el.dataset.i18n); });
224+ root.querySelectorAll('[data-i18n-placeholder]').forEach((el) => { el.placeholder = t(el.dataset.i18nPlaceholder); });
225+ root.querySelectorAll('[data-i18n-title]').forEach((el) => { el.title = t(el.dataset.i18nTitle); });
226+ root.querySelectorAll('[data-i18n-aria-label]').forEach((el) => { el.setAttribute('aria-label', t(el.dataset.i18nAriaLabel)); });
227+}
modified src/main.js +12 −6
@@ -13,6 +13,7 @@
1313 import { canPickFolder, pickAndScanFolder, reopenLastFolder, savedFolderName } from './fsScan.js';
1414 import { detectGPU } from './gpu.js';
1515 import { THEMES } from './themes.js';
16+import { t } from './i18n.js';
1617
1718 const VISUAL_STORAGE_KEY = 'vcc.visualSettings.v1';
1819 const DEFAULT_VISUAL_SETTINGS = {
@@ -206,8 +207,8 @@
206207 city.setModeColors(m.fileColor, m.nodeColor);
207208 ui.setColorLegend(mode === 'blast'
208209 ? [
209- { label: 'Impacto: dependen de él', color: theme.beamIn ?? theme.beam },
210- { label: 'Dependencias: usa de ellos', color: theme.beam },
210+ { label: t('legend.impact'), color: theme.beamIn ?? theme.beam },
211+ { label: t('legend.dependencies'), color: theme.beam },
211212 ]
212213 : m.legend);
213214 ui.setActiveMode(mode);
@@ -268,8 +269,8 @@
268269 }
269270 city.setBlastBeams(pairs);
270271 ui.setColorLegend([
271- { label: `Impacto: dependen de él · ${nImp}`, color: theme.beamIn ?? theme.beam },
272- { label: `Dependencias: usa de ellos · ${nDep}`, color: theme.beam },
272+ { label: `${t('legend.impact')} · ${nImp}`, color: theme.beamIn ?? theme.beam },
273+ { label: `${t('legend.dependencies')} · ${nDep}`, color: theme.beam },
273274 ]);
274275 }
275276
@@ -453,8 +454,8 @@
453454 async function loadScan(scanFn) {
454455 let scan;
455456 try {
456- ui.setLoading('Escaneando…');
457- scan = await scanFn((msg) => ui.setLoading(`Escaneando… ${msg}`));
457+ ui.setLoading(t('analysis.loading'));
458+ scan = await scanFn((msg) => ui.setLoading(t('analysis.loadingDetail', { msg })));
458459 } catch (err) {
459460 if (err?.name !== 'AbortError') console.error(err);
460461 } finally {
@@ -497,6 +498,11 @@
497498 onMode: (mode) => applyColorMode(mode),
498499 onPickFolder: () => loadScan(pickAndScanFolder),
499500 onReopenFolder: () => loadScan(reopenLastFolder),
501+ onLanguageChanged: () => {
502+ if (!model || !city) return;
503+ applyColorMode(colorMode);
504+ if (selectedFile) selectFile(selectedFile);
505+ },
500506 });
501507 ui.setFolderSupported(canPickFolder());
502508 ui.setGpu(gpu);
modified src/ui.js +89 −37
@@ -2,6 +2,7 @@
22 // createUI se llama una sola vez; setModel() reconstruye el árbol cuando se
33 // carga otra carpeta raíz.
44 import { THEMES } from './themes.js';
5+import { applyDocumentTranslations, language, onLanguageChange, setLanguage, t } from './i18n.js';
56
67 function fmtSize(b) {
78 if (b < 1024) return `${b}`;
@@ -51,8 +52,9 @@
5152 function addDirRow(container, node, depth) {
5253 const row = document.createElement('div');
5354 rowNode.set(row, node);
54- const label = node.isBasement ? `${node.name} · sótano` : node.name;
55+ const label = node.isBasement ? `${node.name} · ${t('tree.basementSuffix')}` : node.name;
5556 row.className = 'row dir' + (node.isBasement ? ' basement' : '');
57+ row.dataset.name = node.name;
5658 row.style.paddingLeft = `${depth * 14 + 8}px`;
5759 row.innerHTML = `<span class="caret"></span><span class="name">${label}</span><span class="meta">${node.fileIds.length + node.children.length || ''}</span>`;
5860 const kids = document.createElement('div');
@@ -275,7 +277,7 @@
275277
276278 // ── ruta inferior ───────────────────────────────────────────────────
277279 function setPathParts(names) {
278- if (!names?.length) { pathEl.innerHTML = '<span class="dim">— sin selección · clic en un edificio o busca un fichero —</span>'; return; }
280+ if (!names?.length) { pathEl.innerHTML = `<span class="dim">${t('path.none')}</span>`; return; }
279281 const sep = '<span class="sep">/</span>';
280282 const head = names.slice(0, -1).map(n => `<span class="seg">${n}</span>`).join(sep);
281283 const last = `<span class="seg last">${names[names.length - 1]}</span>`;
@@ -309,17 +311,24 @@
309311 folderBtn.addEventListener('click', () => cb.onPickFolder?.());
310312 const reopenBtn = $('btn-reopen');
311313 reopenBtn.addEventListener('click', () => cb.onReopenFolder?.());
314+ let reopenName = '';
312315 function setReopen(name) {
316+ reopenName = name || '';
313317 reopenBtn.style.display = name ? '' : 'none';
314- if (name) reopenBtn.textContent = `Reabrir ${name}`;
318+ if (name) reopenBtn.textContent = t('button.reopen', { name });
315319 }
316320
321+ // ── selector de idioma ──────────────────────────────────────────────
322+ const langSel = $('lang-select');
323+ langSel.value = language();
324+ langSel.addEventListener('change', () => { setLanguage(langSel.value); langSel.blur(); });
325+
317326 // ── selector de tema ────────────────────────────────────────────────
318327 const themeSel = $('theme-select');
319- for (const [key, t] of Object.entries(THEMES)) {
328+ for (const [key, theme] of Object.entries(THEMES)) {
320329 const opt = document.createElement('option');
321330 opt.value = key;
322- opt.textContent = `Tema · ${t.label}`;
331+ opt.textContent = t('theme.prefix', { label: theme.label });
323332 themeSel.appendChild(opt);
324333 }
325334 themeSel.addEventListener('change', () => { cb.onTheme?.(themeSel.value); themeSel.blur(); });
@@ -332,24 +341,24 @@
332341 const settingsClose = $('settings-close');
333342 const settingsReset = $('settings-reset');
334343 const sliderDefs = [
335- ['exposure', 'Exposición', 0.65, 1.8, 0.01],
336- ['brightness', 'Brillo', 0.75, 1.45, 0.01],
337- ['contrast', 'Contraste', 0.8, 1.8, 0.01],
338- ['saturate', 'Saturación', 0.6, 2.4, 0.01],
339- ['lines', 'Aristas', 0.45, 2.2, 0.01],
340- ['files', 'Celdas', 0.45, 2.4, 0.01],
341- ['glass', 'Cristal', 0.35, 2.2, 0.01],
342- ['facades', 'Fachadas', 0.2, 1.8, 0.01],
343- ['labels', 'Rótulos', 0.2, 2.4, 0.01],
344- ['ground', 'Suelo', 0.25, 1.5, 0.01],
345- ['fog', 'Niebla', 0.35, 1.8, 0.01],
344+ ['exposure', 'settings.exposure', 0.65, 1.8, 0.01],
345+ ['brightness', 'settings.brightness', 0.75, 1.45, 0.01],
346+ ['contrast', 'settings.contrast', 0.8, 1.8, 0.01],
347+ ['saturate', 'settings.saturate', 0.6, 2.4, 0.01],
348+ ['lines', 'settings.lines', 0.45, 2.2, 0.01],
349+ ['files', 'settings.files', 0.45, 2.4, 0.01],
350+ ['glass', 'settings.glass', 0.35, 2.2, 0.01],
351+ ['facades', 'settings.facades', 0.2, 1.8, 0.01],
352+ ['labels', 'settings.labels', 0.2, 2.4, 0.01],
353+ ['ground', 'settings.ground', 0.25, 1.5, 0.01],
354+ ['fog', 'settings.fog', 0.35, 1.8, 0.01],
355+ ];
356+ const presets = [
357+ ['preset.safe', null],
358+ ['preset.neon', { exposure: 1.24, brightness: 1.08, contrast: 1.28, saturate: 1.65, lines: 1.22, files: 1.35, glass: 1.16, facades: 1.12, labels: 1.45, ground: 1.08, fog: 0.92 }],
359+ ['preset.cinema', { exposure: 1.12, brightness: 0.98, contrast: 1.45, saturate: 1.28, lines: 1.05, files: 1.18, glass: 0.95, facades: 1.05, labels: 1.25, ground: 0.82, fog: 1.22 }],
360+ ['preset.intense', { exposure: 1.34, brightness: 1.12, contrast: 1.55, saturate: 2.0, lines: 1.55, files: 1.75, glass: 1.35, facades: 1.35, labels: 1.85, ground: 1.18, fog: 0.78 }],
346361 ];
347- const presets = {
348- Seguro: null,
349- Neón: { exposure: 1.24, brightness: 1.08, contrast: 1.28, saturate: 1.65, lines: 1.22, files: 1.35, glass: 1.16, facades: 1.12, labels: 1.45, ground: 1.08, fog: 0.92 },
350- Cine: { exposure: 1.12, brightness: 0.98, contrast: 1.45, saturate: 1.28, lines: 1.05, files: 1.18, glass: 0.95, facades: 1.05, labels: 1.25, ground: 0.82, fog: 1.22 },
351- Intenso: { exposure: 1.34, brightness: 1.12, contrast: 1.55, saturate: 2.0, lines: 1.55, files: 1.75, glass: 1.35, facades: 1.35, labels: 1.85, ground: 1.18, fog: 0.78 },
352- };
353362 const settingInputs = new Map();
354363
355364 function syncSettings(v) {
@@ -364,10 +373,11 @@
364373 bloomBox.checked = cb.isBloomEnabled?.() ?? false;
365374 }
366375
367- for (const [name, values] of Object.entries(presets)) {
376+ for (const [labelKey, values] of presets) {
368377 const btn = document.createElement('button');
369378 btn.type = 'button';
370- btn.textContent = name;
379+ btn.dataset.i18n = labelKey;
380+ btn.textContent = t(labelKey);
371381 btn.addEventListener('click', () => {
372382 const next = cb.onVisualPreset?.(values);
373383 syncSettings(next);
@@ -378,7 +388,7 @@
378388 for (const [key, label, min, max, step] of sliderDefs) {
379389 const row = document.createElement('label');
380390 row.className = 'setting-row';
381- row.innerHTML = `<span>${label}</span><input type="range" min="${min}" max="${max}" step="${step}"><output></output>`;
391+ row.innerHTML = `<span data-i18n="${label}">${t(label)}</span><input type="range" min="${min}" max="${max}" step="${step}"><output></output>`;
382392 const input = row.querySelector('input');
383393 const output = row.querySelector('output');
384394 input.addEventListener('input', () => {
@@ -423,11 +433,12 @@
423433 if (btn) {
424434 btn.disabled = !ok;
425435 const why = {
426- git: 'sin datos git (ni .git/index legible)',
427- ownership: 'sin reglas de code ownership',
428- blast: 'sin relaciones de código detectadas',
436+ git: 'modeUnavailable.git',
437+ ownership: 'modeUnavailable.ownership',
438+ blast: 'modeUnavailable.blast',
429439 };
430- btn.title = ok ? '' : (why[mode] ?? '');
440+ btn.dataset.available = ok ? '1' : '0';
441+ btn.title = ok ? '' : t(why[mode] ?? '');
431442 }
432443 }
433444
@@ -446,35 +457,76 @@
446457 }
447458
448459 function setFolderSupported(ok) { folderBtn.style.display = ok ? '' : 'none'; }
460+ let loadingMsg = '';
449461 function setLoading(msg) {
462+ loadingMsg = msg || '';
450463 folderBtn.disabled = !!msg;
451464 reopenBtn.disabled = !!msg;
452- folderBtn.textContent = msg || 'Abrir Carpeta…';
465+ folderBtn.textContent = msg || t('button.openFolder');
453466 }
454467
455468 // ── stats / modo vuelo ──────────────────────────────────────────────
456469 let baseFileCount = 0;
457470 let gpuLabel = '';
471+ let lastGpu = null;
458472 function setGpu(gpu) {
473+ lastGpu = gpu;
459474 if (!gpu) { gpuLabel = ''; return; }
460- const mode = gpu.bloom ? `bloom ×${gpu.msaaSamples}` : 'render directo';
461- if (gpu.tier === 'software') gpuLabel = ` · render software · ${mode}`;
462- else if (gpu.tier === 'alta') gpuLabel = ` · GPU ${gpu.brand || 'discreta'} · ${mode}`;
463- else gpuLabel = ` · ${mode}`;
475+ const mode = gpu.bloom ? `bloom ×${gpu.msaaSamples}` : t('gpu.direct');
476+ if (gpu.tier === 'software') gpuLabel = t('gpu.software', { mode });
477+ else if (gpu.tier === 'alta') gpuLabel = t('gpu.high', { brand: gpu.brand || t('gpu.discrete'), mode });
478+ else gpuLabel = t('gpu.other', { mode });
464479 }
465480 // progreso del análisis perezoso del modo Blast (lotes en segundo plano)
466481 let analysisLabel = '';
482+ let lastFps = 0;
467483 function setAnalysis(msg) { analysisLabel = msg ? ` · ${msg}` : ''; }
468484 function setStats(fps) {
469- const urbs = model.urbs?.length ? ` · ${model.urbs.length} urbanizaciones` : '';
470- statsEl.textContent =
471- `${baseFileCount} ficheros + ${model.files.length - baseFileCount} ignorados · ${model.buildings.length} edificios${urbs} · ${model.districts.length} distritos · ${fps} fps${gpuLabel}${analysisLabel}`;
485+ lastFps = fps;
486+ if (!model) return;
487+ const urbs = model.urbs?.length ? t('stats.urbs', { count: model.urbs.length }) : '';
488+ statsEl.textContent = t('stats.main', {
489+ base: baseFileCount,
490+ ignored: model.files.length - baseFileCount,
491+ buildings: model.buildings.length,
492+ urbs,
493+ districts: model.districts.length,
494+ fps,
495+ gpu: gpuLabel,
496+ analysis: analysisLabel,
497+ });
472498 }
473499
474500 function setFlyMode(on) {
475501 document.body.classList.toggle('flying', on);
476502 }
477503
504+ function refreshBasementLabels() {
505+ treeEl.querySelectorAll('.row.dir.basement').forEach((row) => {
506+ const nameEl = row.querySelector('.name');
507+ if (nameEl) nameEl.textContent = `${row.dataset.name} · ${t('tree.basementSuffix')}`;
508+ });
509+ }
510+
511+ function refreshLanguage() {
512+ applyDocumentTranslations();
513+ langSel.value = language();
514+ for (const opt of themeSel.options) opt.textContent = t('theme.prefix', { label: THEMES[opt.value].label });
515+ setReopen(reopenName);
516+ if (!loadingMsg) folderBtn.textContent = t('button.openFolder');
517+ for (const btn of modeBtns) {
518+ if (btn.dataset.available === '0') setModeAvailable(btn.dataset.mode, false);
519+ }
520+ refreshBasementLabels();
521+ if (pathEl.querySelector('.dim')) setPath(null);
522+ setGpu(lastGpu);
523+ setStats(lastFps);
524+ cb.onLanguageChanged?.();
525+ }
526+
527+ refreshLanguage();
528+ onLanguageChange(refreshLanguage);
529+
478530 return {
479531 setModel, markFile, markNode, setPath, setPathParts, setStats, setGpu, setAnalysis, setFlyMode, hideResults,
480532 setFolderSupported, setLoading, setActiveMode, setModeAvailable, setColorLegend, setReopen,