Skip to content

Astro i18n Next

Translated URL routing, content localization, multilingual markdown, and i18next integration — all through a single createI18n() call.

Features

Translated URL Routing

Automatic locale-prefixed paths for all your pages. /about/ becomes /es/sobre/ — no dynamic slugs or catch-all routes needed.

Virtual Module

Import t, localePath, switchLocalePath, and more from virtual:i18n. One import, all the i18n helpers you need.

Multilingual Markdown

Write all locales in a single markdown file with YAML frontmatter and <!-- locale:es --> body markers. Powered by Astro 5’s Content Loader API.

i18next Integration

Full i18next support with dot-notation keys, fallback chains, and plugin extensibility (ICU, interpolation, and more).

Page Slug Translation

Export slugs from .astro pages to define per-locale URL segments. Auto-discovered at build time — no config needed.

Fully Static

Designed for Astro’s static output. All routes are prerendered with zero runtime overhead.

Quick Example

astro.config.mjs
import { createI18n } from '@otrodigital/astro-i18n-next';
export default defineConfig({
integrations: [createI18n({
defaultLocale: 'en',
locales: ['en', 'es'],
localeLabels: { en: 'English', es: 'Español' },
localeHtmlLang: { en: 'en', es: 'es' },
translations: { en, es },
pagesDir: 'src/pages',
})],
});
---
// Any .astro component
import { t, localePath } from 'virtual:i18n';
const locale = Astro.locals.locale;
---
<h1>{t(locale, 'home.title')}</h1>
<a href={localePath(locale, '/about/')}>{t(locale, 'nav.about')}</a>