Overview
Jowy Portfolio includes built-in internationalization (i18n) support with Spanish and English languages. The i18n configuration is managed through Astro’s native i18n routing system.Configuration
The i18n configuration is defined ini18n.config.ts at the project root:
Supported Locales
Array of supported language codes. Currently supports Spanish (
es) and English (en).The default language for the site. Set to Spanish (
es).TypeScript type alias for supported languages:
"es" | "en"Astro i18n Integration
The i18n configuration is integrated into Astro’s configuration inastro.config.mjs:
Routing Configuration
The default locale for the site, imported from
i18n.config.ts.Array of all supported locales, imported from
i18n.config.ts.When
false, the default locale (Spanish) URLs don’t include the language prefix.- Spanish:
/about(no prefix) - English:
/en/about(with prefix)
Automatically redirects the root path to the default locale when
prefixDefaultLocale is false.URL Structure
With the current configuration:Spanish (Default)
English
Since
prefixDefaultLocale is false, Spanish URLs (the default language) don’t include /es in the path.Adding a New Language
To add support for a new language:- Update
i18n.config.tsto include the new locale:
- Create language-specific content directories:
- Add translations for UI elements and content.
- Restart your development server.
Changing the Default Language
To change the default language from Spanish to English:- Update
i18n.config.ts:
- Rebuild your site:
Changing the default language will affect your URL structure. Users with bookmarks to the old default language URLs may need to update them.
Language Detection
Astro’s i18n routing automatically handles:- URL-based locale detection
- Fallback to default locale for unsupported languages
- Proper redirects based on routing configuration
TypeScript Support
TheLang type provides type safety throughout your application:
Best Practices
Keep content structure consistent
Keep content structure consistent
Maintain the same page structure across all locales to ensure consistent user experience.
Use locale-aware date/time formatting
Use locale-aware date/time formatting
Format dates and times according to each locale’s conventions using
Intl.DateTimeFormat.Translate metadata
Translate metadata
Don’t forget to translate page titles, descriptions, and other SEO metadata for each language.
Handle RTL languages
Handle RTL languages
If adding right-to-left languages (Arabic, Hebrew), configure appropriate text direction in your styles.
Troubleshooting
Language switcher not working
- Verify the
i18nconfiguration inastro.config.mjsmatchesi18n.config.ts - Ensure page files exist for all supported locales
- Check that locale prefixes in links are correct
404 errors on translated pages
- Confirm the page exists in the corresponding locale directory (e.g.,
src/pages/en/) - Rebuild the site after adding new pages
- Verify routing configuration in
astro.config.mjs
Default language showing prefix
- Check that
prefixDefaultLocaleis set tofalseinastro.config.mjs - Clear your browser cache and restart the dev server