diff --git a/client/I18N_README.md b/client/I18N_README.md new file mode 100644 index 00000000..331dd8e3 --- /dev/null +++ b/client/I18N_README.md @@ -0,0 +1,240 @@ +# Internationalization (i18n) Setup + +This project includes a comprehensive internationalization system built with Astro 5.x. The system supports multiple languages with URL-based routing and automatic language detection. + +## Features + +- ✅ URL-based language routing (Spanish: `/`, English: `/en/`) +- ✅ Spanish as default language (no URL prefix) +- ✅ Automatic language detection from URL +- ✅ Language switcher component +- ✅ Type-safe translation keys +- ✅ Fallback to default language +- ✅ Middleware for automatic redirects +- ✅ SEO-friendly URLs + +## Supported Languages + +Currently supported languages: +- **Spanish (es)** - Default language (no URL prefix) +- **English (en)** - Secondary language (with `/en/` prefix) + +## URL Structure + +- **Spanish (default)**: `/`, `/elements`, `/about` +- **English**: `/en/`, `/en/elements`, `/en/about` + +## How to Use + +### 1. Adding New Translations + +Edit the translation dictionaries in `src/lib/i18n.ts`: + +```typescript +const translations = { + es: { + 'your.new.key': 'Texto en español', + // ... more translations + }, + en: { + 'your.new.key': 'English text', + // ... more translations + } +} +``` + +### 2. Using Translations in Components + +```astro +--- +import { t, getLanguageFromPath } from '../lib/i18n'; + +const currentLang = getLanguageFromPath(Astro.url.pathname); +--- + +