$npx -y skills add fusengine/agents --skill astro-i18nUse when implementing internationalization in Astro, configuring i18n routing, setting up locale strategies, using getRelativeLocaleUrl/getAbsoluteLocaleUrl, handling Astro.currentLocale, or adding hreflang tags with sitemap.
| 1 | # Astro i18n |
| 2 | |
| 3 | ## Agent Workflow (MANDATORY) |
| 4 | |
| 5 | Before ANY implementation, use `TeamCreate` to spawn 3 agents: |
| 6 | |
| 7 | 1. **fuse-ai-pilot:explore-codebase** - Analyze existing routing, content collections, and locale files |
| 8 | 2. **fuse-ai-pilot:research-expert** - Verify latest Astro i18n docs via Context7/Exa |
| 9 | 3. **mcp__context7__query-docs** - Check `astro:i18n` API and sitemap integration |
| 10 | |
| 11 | After implementation, run **fuse-ai-pilot:sniper** for validation. |
| 12 | |
| 13 | --- |
| 14 | |
| 15 | ## Overview |
| 16 | |
| 17 | ### When to Use |
| 18 | |
| 19 | - Building multilingual Astro sites with locale-prefixed URLs |
| 20 | - Configuring `defaultLocale` and routing strategies |
| 21 | - Generating locale-aware links with `getRelativeLocaleUrl()` |
| 22 | - Reading `Astro.currentLocale` in components and pages |
| 23 | - Adding `hreflang` alternate links via `@astrojs/sitemap` |
| 24 | - Translating content using Content Collections per locale |
| 25 | |
| 26 | ### Built-in i18n (Astro 3.5+) |
| 27 | |
| 28 | Astro's built-in i18n system provides: |
| 29 | - File-based locale routing via `src/pages/[locale]/` |
| 30 | - Routing strategies for URL prefix behavior |
| 31 | - URL helper functions from `astro:i18n` |
| 32 | - Middleware-based routing logic |
| 33 | - Fallback locale configuration |
| 34 | |
| 35 | --- |
| 36 | |
| 37 | ## Reference Guide |
| 38 | |
| 39 | ### Concepts |
| 40 | |
| 41 | | Topic | Reference | When to Consult | |
| 42 | |-------|-----------|-----------------| |
| 43 | | Routing config | [routing-config.md](references/routing-config.md) | Setup and config options | |
| 44 | | Strategies | [strategies.md](references/strategies.md) | prefix-always vs prefix-other-locales | |
| 45 | | Helper functions | [helper-functions.md](references/helper-functions.md) | getRelativeLocaleUrl and all helpers | |
| 46 | | Content translation | [content-translation.md](references/content-translation.md) | Translating content collections | |
| 47 | | Sitemap hreflang | [sitemap-hreflang.md](references/sitemap-hreflang.md) | SEO alternate links | |
| 48 | | Fallback | [fallback.md](references/fallback.md) | Missing translation fallback | |
| 49 | |
| 50 | ### Templates |
| 51 | |
| 52 | | Template | When to Use | |
| 53 | |----------|-------------| |
| 54 | | [i18n-config.md](references/templates/i18n-config.md) | Full i18n configuration | |
| 55 | | [locale-page.md](references/templates/locale-page.md) | Page component with locale awareness | |
| 56 | | [language-switcher.md](references/templates/language-switcher.md) | Language switcher component | |
| 57 | |
| 58 | --- |
| 59 | |
| 60 | ## Best Practices |
| 61 | |
| 62 | 1. **Use `getRelativeLocaleUrl()`** — never hardcode locale prefixes in links |
| 63 | 2. **`Astro.currentLocale`** — read locale in components, not from URL manually |
| 64 | 3. **Content Collections per locale** — organize translated content in `src/content/[type]/[locale]/` |
| 65 | 4. **Sitemap hreflang** — always configure `@astrojs/sitemap` with `i18n` option for SEO |
| 66 | 5. **Fallback locales** — configure `fallback` to prevent 404s for missing translations |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## Forbidden |
| 71 | |
| 72 | - Hardcoding locale strings in URL paths |
| 73 | - Parsing the URL manually to detect locale (use `Astro.currentLocale`) |
| 74 | - Skipping hreflang configuration for SEO-sensitive sites |
| 75 | - Using `getRelativeLocaleUrl` without configuring `site` in Astro config |