Skip to content

Add i18n support with Spanish and English locales#26

Merged
sergiomarquezdev merged 2 commits into
mainfrom
claude/add-portfolio-translations-o46yz
Feb 15, 2026
Merged

Add i18n support with Spanish and English locales#26
sergiomarquezdev merged 2 commits into
mainfrom
claude/add-portfolio-translations-o46yz

Conversation

@sergiomarquezdev

Copy link
Copy Markdown
Owner

Summary

This PR adds full internationalization (i18n) support to the portfolio, enabling Spanish and English language versions with locale-specific CV data, UI strings, and routing.

Key Changes

  • Locale System: Implemented i18n infrastructure with Spanish (es) as default and English (en) as secondary locale

    • Created src/i18n/index.ts with translation strings for navigation, SEO, ARIA labels, and structured data
    • Added getLocale() helper to detect and manage locale from Astro's currentLocale
  • Multi-locale CV Data:

    • Added public/cv.es.json with Spanish CV content (Sergio's full professional profile)
    • Refactored src/data/cv.ts to support dynamic locale loading via getCv(locale) function
    • Pre-loads all locales at build time for performance
  • Routing & Navigation:

    • Configured Astro i18n routing: / for Spanish, /en/ for English
    • Created src/pages/en/index.astro for English route
    • Updated src/pages/index.astro to use locale-aware CV data
    • Added LanguageSwitcher component for easy locale switching
  • Locale Detection & Persistence:

    • Implemented browser language detection with localStorage persistence
    • Auto-redirects English speakers to /en/ on first visit
    • Respects user preference on subsequent visits
  • SEO & Metadata:

    • Updated BaseHead.astro with hreflang alternate links for both locales
    • Made OG meta tags, page titles, and descriptions locale-aware
    • Structured data (schema.org) now uses translated knowsAbout array
  • Component Updates:

    • Updated all section components (Experience, Projects, Certifications, Navigation) to use translated strings
    • Modified Layout and sidebar components to support locale-aware home links
    • Added language switcher to both mobile header and desktop sidebar
  • Testing:

    • Enhanced src/data/__tests__/cv.test.ts with comprehensive locale validation
    • Added tests for structural parity between locales and content differences

Implementation Details

  • Locale detection uses Astro.currentLocale from the i18n routing configuration
  • CV data is loaded synchronously at build time and cached for performance
  • Language switcher persists user preference to localStorage to avoid repeated redirects
  • All UI strings are centralized in src/i18n/index.ts for easy maintenance
  • Maintains backward compatibility with existing cv export for tests and legacy code

https://claude.ai/code/session_01Nhp3Z1188ksAqD4FnZ6ff6

- Split cv.json into cv.es.json and cv.en.json with full translations
- Configure Astro i18n routing (/ = es, /en/ = en)
- Add i18n utility module with UI translation strings and locale helpers
- Update cv.ts loader with getCv(locale) for locale-aware data loading
- Add automatic language detection via navigator.language on first visit
- Add subtle language switcher (ES/EN) in sidebar and mobile header
- Update all components with locale-aware section titles, nav labels, and aria-labels
- Add hreflang tags (es, en, x-default) and locale-specific og:locale
- Localize structured data (JSON-LD) per language
- Update tests to validate both locale data files

https://claude.ai/code/session_01Nhp3Z1188ksAqD4FnZ6ff6
- Wrap localStorage calls in try-catch for private browsing compatibility
- Translate Navigation aria-label ("Navegación principal" / "Main navigation")
- Localize knowsAbout in JSON-LD structured data per locale
- Add sitemap i18n config for xhtml:link hreflang alternates in XML
- Extract shared HomePage.astro to deduplicate page templates
- Use canonicalURL consistently for og:url and twitter:url
- Add structural parity test between locale JSON files

https://claude.ai/code/session_01Nhp3Z1188ksAqD4FnZ6ff6
@sergiomarquezdev sergiomarquezdev merged commit b5ce680 into main Feb 15, 2026
2 checks passed
@sergiomarquezdev sergiomarquezdev deleted the claude/add-portfolio-translations-o46yz branch February 15, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants