翻訳済みURLルーティング
すべてのページに自動的なロケールプレフィックスパス。/about/ が /es/sobre/ に — 動的slugやキャッチオールルートは不要。
createI18n()呼び出しで。翻訳済みURLルーティング
すべてのページに自動的なロケールプレフィックスパス。/about/ が /es/sobre/ に — 動的slugやキャッチオールルートは不要。
仮想モジュール
virtual:i18n から t、localePath、switchLocalePath などをインポート。1つのインポートで必要なi18nヘルパーすべてが利用可能。
多言語Markdown
YAMLフロントマターと <!-- locale:es --> ボディマーカーを使用して、1つのMarkdownファイルにすべてのロケールを記述。Astro 5のContent Loader APIを活用。
i18next統合
ドット記法キー、フォールバックチェーン、プラグイン拡張性(ICU、補間など)を備えた完全なi18nextサポート。
ページSlug翻訳
.astro ページから slugs をエクスポートして、ロケールごとのURLセグメントを定義。ビルド時に自動検出 — 設定不要。
完全な静的出力
Astroの静的出力用に設計。すべてのルートがランタイムオーバーヘッドなしでプリレンダリング。
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', })],});---// 任意の .astro コンポーネント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>