Skip to content

Add i18n support with English and Spanish locales#33

Merged
usarral merged 4 commits into
mainfrom
claude/i18n-spanish-english-5e737
May 23, 2026
Merged

Add i18n support with English and Spanish locales#33
usarral merged 4 commits into
mainfrom
claude/i18n-spanish-english-5e737

Conversation

@usarral
Copy link
Copy Markdown
Owner

@usarral usarral commented May 23, 2026

What kind of changes does this PR include?

  • Changes with larger consequences (logic, library updates, etc.)

Description

This PR adds comprehensive internationalization (i18n) support to the site, enabling English and Spanish language versions.

Key Changes:

  • i18n Infrastructure: Added src/i18n/config.ts and src/i18n/utils.ts to manage locales, translations, and path switching
  • Translation System: Created src/i18n/ui.ts with complete English and Spanish translations for all UI strings (navigation, labels, page content, etc.)
  • Localized Projects: Updated src/data/projects.ts to support bilingual project descriptions with a new LocalizedString interface and getLocalizedProjects() function
  • Localized Posts: Modified post collection to include a lang field and added getPostsByLocale() function to filter posts by language
  • Route Structure: Reorganized pages under [lang] parameter routes (/en/, /es/) with locale-aware routing
  • Language Toggle: Added LangToggle.astro component with dropdown menu for switching between languages, with cookie persistence
  • Root Redirect: Updated root index.astro to detect user's language preference (from cookie or browser) and redirect to appropriate locale
  • Astro Config: Configured Astro's i18n routing with prefix for default locale and proper sitemap generation for both locales
  • Component Updates: Updated all layout and component files to accept and use locale prop for proper language context
  • 404 & RSS: Created locale-specific 404 and RSS feed pages

Removed:

  • Old non-localized pages (/about.astro, /tags/index.astro, /posts/[...page].astro, /projects.astro, /rss.xml.ts)

All content is now available in both English and Spanish with proper URL structure and language switching capabilities.

Test Plan

  • Verify navigation between /en/ and /es/ routes works correctly
  • Test language toggle component switches locale and persists selection via cookie
  • Confirm all translated strings display correctly in both languages
  • Verify posts filter by language and only show appropriate content per locale
  • Check that project descriptions display in the correct language
  • Test RSS feeds generate for both locales at /en/rss.xml and /es/rss.xml
  • Verify root redirect detects browser language and cookie preferences appropriately

https://claude.ai/code/session_01BmNYbBgWnGBDQ134Cs97S2

…nual switch

- Add Astro i18n config with /en/ and /es/ prefixed routes
- Move pages under src/pages/[lang]/ generating both locales
- Root / detects navigator.language + remembered cookie, redirects accordingly
- Add LangToggle in header that swaps locale on the current path and persists the choice
- Translate UI strings (nav, home, projects, posts, tags, 404, RSS) via src/i18n
- Make post schema lang-aware (default en) and tag existing Spanish drafts as lang: es
- Localize project data, dates and OG metadata; emit hreflang alternates + per-locale RSS

https://claude.ai/code/session_01BmNYbBgWnGBDQ134Cs97S2
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
usarral-2026-site Ready Ready Preview, Comment May 23, 2026 9:36pm

@usarral usarral merged commit 0b84ef4 into main May 23, 2026
3 checks passed
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