Configuration options
Look up these options after completing Quick start. They are not additional installation steps.
Complete basic configuration
This is the same example as the tutorial. Add the integration to your existing configuration.
import { defineConfig } from "astro/config";
import astroIntl from "astro-intl";
import en from "./src/i18n/messages/en.json" with { type: "json" };
import es from "./src/i18n/messages/es.json" with { type: "json" };
export default defineConfig({
integrations: [
astroIntl({
defaultLocale: "en",
locales: ["en", "es"],
messages: { en, es },
}),
],
});defaultLocale / locales
defaultLocale is 'en' when omitted. locales lists allowed languages; use the same list when generating pages. The integration does not generate [lang] or getStaticPaths for you.
messages
Maps each language to a message object or loader function. Start with the imported JSON objects shown above. You do not need request.ts.
messagesDir
An alternative to messages that loads locale files from a directory. Requires locales. Do not combine it with messages: messages takes precedence. Path resolution and JSON availability in production need project-specific verification; the recommended tutorial uses explicit imports.
routes
Optional map of translated URLs. See Translated routes and configure its middleware; it is not needed for /es/ and /en/.
enabled
Defaults to true. Controls integration hooks. It does not replace removing translation calls from your pages.