No slash command · from anglesite
Adds multi-language support to an Astro site with localized routes, hreflang tags, and a language switcher. Useful when a site needs content in multiple languages.
Ships in anglesite. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Add multi-language support to the site. Not invoked directly by the owner.
${CLAUDE_PLUGIN_ROOT}/template/scripts/i18n.ts holds reference implementations of the config, hreflang tags, and language switcher described below — read it for the exact output. A skill cannot call those functions, so write the equivalent config and markup by hand as each step shows.
Ask the owner: "Does your business serve customers who speak languages other than English? For example, many [business type] businesses offer their site in Spanish too."
If yes, ask which languages. Common combinations for US small businesses:
Supported language codes are in SUPPORTED_LANGUAGES in scripts/i18n.ts.
Save to .site-config:
SITE_LANGUAGES=en,es
DEFAULT_LANGUAGE=en
Use the Edit tool to add an i18n block to the existing defineConfig({ ... }) call in astro.config.ts, built from DEFAULT_LANGUAGE and SITE_LANGUAGES. Leave the rest of the config untouched:
export default defineConfig({
site: siteUrl,
i18n: {
defaultLocale: "en",
locales: ["en", "es"],
routing: {
prefixDefaultLocale: false,
},
},
// ... rest of config
});
This gives URL structure:
/blog/post — English (default, no prefix)/es/blog/post — SpanishCreate parallel content directories for the non-default locale(s):
src/content/posts/ ← English posts (existing)
src/content/posts/es/ ← Spanish posts
src/content/services/ ← English services
src/content/services/es/ ← Spanish services
Each translated entry has the same filename as its English counterpart. This allows matching content across languages.
Astro loads everything under src/content/posts/ — subfolders included — into the one posts collection (see src/content.config.ts). A Spanish entry gets the id es/<filename> and would otherwise show up in the English blog and feed. Keep the languages apart by id prefix everywhere a translated collection is queried.
In the existing English pages — src/pages/blog/index.astro, src/pages/blog/archive.astro, src/pages/blog/[slug].astro, src/pages/rss.xml.ts, and any page that lists another translated collection — use the Edit tool to extend the getCollection filter so it also drops entries from the other locales, keeping the filter that is already there:
const otherLocales = ["es"]; // every non-default locale
const posts = await getCollection("posts", ({ id, data }) => {
if (otherLocales.some((locale) => id.startsWith(`${locale}/`))) return false;
return import.meta.env.PROD ? !data.draft : true;
});
Use the Edit tool to add to src/layouts/BaseLayout.astro:
Dynamic lang attribute — change <html lang="en"> to use the current locale from Astro.currentLocale or the URL path.
Hreflang tags — add in the <head> section: one <link rel="alternate"> per language for the current page, plus an x-default pointing at the default-language URL:
<!-- Hreflang for SEO -->
<link rel="alternate" hreflang="en" href="https://example.com/blog/post" />
<link rel="alternate" hreflang="es" href="https://example.com/es/blog/post" />
<link rel="alternate" hreflang="x-default" href="https://example.com/blog/post" />
aria-current="page" on the current one:<nav aria-label="Language" class="language-switcher">
<a href="/blog/post" aria-current="page" lang="en">English</a>
<a href="/es/blog/post" lang="es">Español</a>
</nav>
For each non-default locale, create page files under the locale directory:
src/pages/es/index.astro
src/pages/es/blog/index.astro
src/pages/es/blog/[slug].astro
These mirror the English pages, but their getCollection filter keeps only entries whose id starts with the locale prefix (es/), and the slug param is the id with that prefix removed — so src/content/posts/es/hello.mdoc is served at /es/blog/hello.
Create RSS feeds per language:
/rss.xml — English posts (already filtered in Step 3)/es/rss.xml — Spanish postsUpdate the RSS title and description for each language.
Create a simple translation object for UI strings (button labels, navigation, footer text):
const ui = {
en: { readMore: "Read more", subscribe: "Subscribe", contact: "Contact" },
es: { readMore: "Leer más", subscribe: "Suscribirse", contact: "Contacto" },
};
Store in src/i18n/ui.ts. Pages import the current locale's strings.
npm run build
npx astro check
Then confirm the languages stayed apart: use Glob on dist/blog/es/** — it must match nothing. Translated posts belong only under dist/es/. If it matches, a page from Step 3 is still missing the locale filter.
Tell the owner: "Your site now supports [languages]. Here's how it works:"
example.com — English version (default)example.com/es/ — Spanish versionWhen the owner creates content in their default language, offer: "Would you like me to translate this to [other language]?"
If yes, translate the content and create the parallel file. The owner can review and edit the translation in Keystatic.
Translations are always editable — the AI provides a starting point, not a final product.
After setup, update:
docs/architecture.md — note multi-language support and URL structure.site-config — SITE_LANGUAGES and DEFAULT_LANGUAGEWhat SKILL.md sets; muted values are Claude Code's defaults
Use when the site needs content in more than one language, translated pages, or a language switcher.
npx claudepluginhub anglesite/anglesite-skills --plugin anglesite56 skills in this plugin
/bookingEmbed appointment scheduling (Cal.com or Calendly) into the siteOther plugins' skills for the same job