שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Add useIntlayer, useDictionary, useLocale hooks, middleware, and formatters documentation"v9.5.519.9.2026
- "Unified documentation for all exports"v8.0.021.1.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
astro-intlayer Package
The astro-intlayer package provides the necessary tools to integrate Intlayer into Astro applications. It configures locale-based routing, dictionary management, build-time page rewriting, request middleware, and hooks for accessing multilingual content across both server-rendered .astro components and client-side scripts.
Installation
העתקת הקוד ללוח
Exports
Integration
The astro-intlayer package provides an Astro integration that sets up Intlayer in your project.
Import:
העתקת הקוד ללוח
or default import in astro.config.mjs:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Function | Description | Related Doc |
|---|---|---|
intlayer | Astro integration that prepares dictionaries, configures Vite plugins (aliases, routing proxy, prune), automatically registers request middleware, and emits prerendered pages at localized rewritten URLs. | intlayer |
Hooks (Server & Client)
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Hook | Description | Related Doc |
|---|---|---|
useIntlayer | Picks one dictionary by its key and returns its localized content. In .astro frontmatter, it reads the request locale from Astro.locals. In client <script>, it reads from the client store. | useIntlayer |
useDictionary | Transforms a dictionary object and returns content for the resolved locale. Works in frontmatter and client scripts. | useDictionary |
useLocale | Returns the current locale, default locale, available locales, and a function to update the locale. | useLocale |
Middleware (astro-intlayer/middleware)
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Export | Type | Description | Related Doc |
|---|---|---|---|
onRequest | MiddlewareHandler | Astro middleware that detects the request locale and attaches Astro.locals.intlayer. Registered automatically by intlayer(), or imported manually to compose. | onRequest |
Utilities
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Function | Description | Related Doc |
|---|---|---|
getIntlayerLocals | Helper function to retrieve the current IntlayerLocals object from the request storage scope outside of Astro.locals. | - |
Client Utilities (astro-intlayer/client)
Import:
העתקת הקוד ללוח
When imported in the browser or inside client <script> tags, astro-intlayer automatically maps to astro-intlayer/client (powered by vanilla-intlayer), providing client-side dictionary getters, store subscribers, and locale persistence tools.
Formatters (astro-intlayer/format)
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Hook | Description |
|---|---|
useIntl | Returns an Intl instance bound to the request or client locale with caching and subscription capabilities. |
useDate | Returns a date formatting function pre-bound to the current locale (Intl.DateTimeFormat). |
useNumber | Returns a number formatting function pre-bound to the current locale (Intl.NumberFormat). |
useCurrency | Returns a currency formatting function pre-bound to the current locale. |
usePercentage | Returns a percentage formatting function pre-bound to the current locale. |
useRelativeTime | Returns a relative time formatting function pre-bound to the current locale (Intl.RelativeTimeFormat). |
useList | Returns a list formatting function pre-bound to the current locale (Intl.ListFormat). |
useUnit | Returns a unit formatting function pre-bound to the current locale. |
useCompact | Returns a compact number formatting function pre-bound to the current locale (e.g. 1.5K). |
HTML Utilities (astro-intlayer/html)
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Export | Type | Description |
|---|---|---|
renderHTML | Function | Standalone utility function to render HTML nodes. |
useHTML | Hook | Hook to get the HTML provider context and configuration. |
useHTMLRenderer | Hook | Hook to obtain a pre-configured HTML renderer function. |
Markdown Utilities (astro-intlayer/markdown)
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Export | Type | Description |
|---|---|---|
compileMarkdown | Function | Compiles markdown strings into structured representation. |
renderMarkdown | Function | Renders markdown content into output nodes. |
parseMarkdown | Function | Parses raw markdown content into an AST. |
useMarkdown | Hook | Hook to get the markdown provider context. |
useMarkdownRenderer | Hook | Hook to obtain a pre-configured Markdown renderer function. |
Types
Import:
העתקת הקוד ללוח
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Type | Description |
|---|---|
IntlayerLocals | The object attached to Astro.locals.intlayer containing locale, defaultLocale, and availableLocales. |
UseLocaleProps | Optional configuration properties accepted by useLocale(). |
UseLocaleResult | The return type of useLocale(), providing locale properties and update methods. |
