שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Update integration documentation with middleware and hooks details"v9.5.519.9.2026
- "Init doc"v8.0.021.1.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
intlayer Astro Integration Documentation
The intlayer integration for Astro configures your project for multilingual internationalization (i18n). It handles build-time dictionary preparation, Vite plugin injection, automatic request middleware registration, and emitting localized prerendered pages.
Usage
Add intlayer() to your astro.config.mjs:
העתקת הקוד ללוח
Astro CLI's codemod (astro add astro-intlayer) also generates a default import which is supported:
העתקת הקוד ללוח
Description
The integration hooks into Astro's build and runtime lifecycle:
- Config Setup (
astro:config:setup):- Dictionary Preparation: Prepares Intlayer dictionaries and generated types before the build runs.
- Vite Plugins: Injects plugins for Vite aliases (enabling seamless dictionary imports), locale routing proxies, and build pruning.
- Middleware Registration: Automatically injects
astro-intlayer/middlewareinto your project's middleware chain, populatingAstro.locals.intlayeron every incoming request.
- Build Done (
astro:build:done):- Page Rewrites: Inspects localized URL rewrite rules and emits prerendered HTML pages at their corresponding localized paths.
What is Provided Out of the Box
Once configured, your Astro application can immediately use:
- The
useIntlayer,useDictionary, anduseLocalehooks inside.astrocomponent frontmatter. - The
Astro.locals.intlayerobject in Astro endpoints and pages. - Client-side imports in
<script>blocks that mirror the same API with reactive updates. - Built-in formatters under
astro-intlayer/format(useDate,useNumber,useCurrency, etc.).
