From de0c4437644db13637d073b158216906808a4cf2 Mon Sep 17 00:00:00 2001 From: juanatsap Date: Sun, 9 Nov 2025 20:59:10 +0000 Subject: [PATCH] feat: add bilingual support to info modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added 'ui' section to cv-en.json and cv-es.json with modal translations - Updated Go models to include UI, InfoModal, and TechStack structs - Modified template to use JSON data instead of inline if/else statements - Used template.HTML for Description field to allow HTML rendering - Modal now fully supports English and Spanish translations Translations include: - Modal title - Description text - Tech stack labels (HTML5 Semántico vs Semantic HTML5, etc.) - View source button text --- data/cv-en.json | 13 +++++++++++++ data/cv-es.json | 13 +++++++++++++ internal/models/cv.go | 20 ++++++++++++++++++++ templates/index.html | 18 +++++++----------- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/data/cv-en.json b/data/cv-en.json index 8123143..7bb8336 100644 --- a/data/cv-en.json +++ b/data/cv-en.json @@ -911,6 +911,19 @@ "other": { "driverLicense": "Type B" }, + "ui": { + "infoModal": { + "title": "About this CV", + "description": "This interactive CV was built by myself with Go + HTMX, showcasing modern hypermedia architecture without heavy JavaScript frameworks.", + "techStack": { + "goHono": "Go + Hono", + "htmx": "HTMX", + "html5": "Semantic HTML5", + "css3": "Pure CSS3" + }, + "viewSource": "View Source Code" + } + }, "meta": { "version": "2025-11-09", "lastUpdated": "2025-11-08", diff --git a/data/cv-es.json b/data/cv-es.json index a10e4c2..3f0cb62 100644 --- a/data/cv-es.json +++ b/data/cv-es.json @@ -916,6 +916,19 @@ "other": { "driverLicense": "Tipo B" }, + "ui": { + "infoModal": { + "title": "Acerca de este CV", + "description": "Este CV interactivo fue construido por mí mismo con Go + HTMX, demostrando arquitectura moderna de hipermedia sin frameworks pesados de JavaScript.", + "techStack": { + "goHono": "Go + Hono", + "htmx": "HTMX", + "html5": "HTML5 Semántico", + "css3": "CSS3 Puro" + }, + "viewSource": "Ver código fuente" + } + }, "meta": { "version": "2025-11-09", "lastUpdated": "2025-11-08", diff --git a/internal/models/cv.go b/internal/models/cv.go index f122d43..0d7c900 100644 --- a/internal/models/cv.go +++ b/internal/models/cv.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "fmt" + "html/template" "os" ) @@ -21,6 +22,7 @@ type CV struct { Courses []Course `json:"courses"` References []Reference `json:"references"` Other Other `json:"other"` + UI UI `json:"ui"` Meta Meta `json:"meta"` } @@ -168,6 +170,24 @@ type Meta struct { Language string `json:"language"` } +type UI struct { + InfoModal InfoModal `json:"infoModal"` +} + +type InfoModal struct { + Title string `json:"title"` + Description template.HTML `json:"description"` + TechStack TechStack `json:"techStack"` + ViewSource string `json:"viewSource"` +} + +type TechStack struct { + GoHono string `json:"goHono"` + HTMX string `json:"htmx"` + HTML5 string `json:"html5"` + CSS3 string `json:"css3"` +} + // LoadCV loads CV data from a JSON file for the specified language func LoadCV(lang string) (*CV, error) { // Validate language diff --git a/templates/index.html b/templates/index.html index 8e26381..6129b26 100644 --- a/templates/index.html +++ b/templates/index.html @@ -297,41 +297,37 @@
-

{{if eq .Lang "es"}}Acerca de este CV{{else}}About this CV{{end}}

+

{{.CV.UI.InfoModal.Title}}

CV {{.CurrentYear}} - {JAMR}

- {{if eq .Lang "es"}} - Este CV interactivo fue construido por mí mismo con Go + HTMX, demostrando arquitectura moderna de hipermedia sin frameworks pesados de JavaScript. - {{else}} - This interactive CV was built by myself with Go + HTMX, showcasing modern hypermedia architecture without heavy JavaScript frameworks. - {{end}} + {{.CV.UI.InfoModal.Description}}

- Go + Hono + {{.CV.UI.InfoModal.TechStack.GoHono}}
- HTMX + {{.CV.UI.InfoModal.TechStack.HTMX}}
- Semantic HTML5 + {{.CV.UI.InfoModal.TechStack.HTML5}}
- Pure CSS3 + {{.CV.UI.InfoModal.TechStack.CSS3}}
- {{if eq .Lang "es"}}Ver código fuente{{else}}View Source Code{{end}} + {{.CV.UI.InfoModal.ViewSource}}