מחבר:
הפנו את עוזר ה-AI המועדף עליכם למסמך הזהChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Unified documentation for all exports"v9.4.024.8.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתעריכת המסמך הזה
אם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודנוצר:2026-08-24עדכון אחרון:2026-08-24
העתקה
העתקת ה-Markdown של המסמך ללוח
elysia-intlayer Package
The elysia-intlayer package provides a plugin for Elysia applications to handle internationalization. It detects the user's locale and injects an intlayer object into the route context.
Installation
bash
העתקת קוד
העתקת הקוד ללוח
elysiais a peer dependency (>=1.0.0). Elysia targets the Bun runtime.
Exports
Plugin
Import:
ts
העתקת קוד
העתקת הקוד ללוח
הצגת כל תוכן הטבלה
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Function | Description | Related Doc |
|---|---|---|
intlayer | Elysia plugin that integrates Intlayer into your Elysia application. Handles locale detection from storage (cookie, header) then from Accept-Language, injects an intlayer object exposing locale, t, getIntlayer and getDictionary into the route context, and sets up the AsyncLocalStorage request context. | intlayer |
Functions
Import:
ts
העתקת קוד
העתקת הקוד ללוח
הצגת כל תוכן הטבלה
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Function | Description | Related Doc |
|---|---|---|
t | Global translation function that retrieves content for the current locale in Elysia. Uses AsyncLocalStorage to access the request context set up by the intlayer plugin, and falls back to the default locale outside of it. Can also be accessed via intlayer.t. | translation |
getIntlayer | Retrieves a dictionary by its key from the generated declaration and returns its content for the current locale. Optimized version of getDictionary. Uses AsyncLocalStorage to access the request context. Can also be accessed via intlayer.getIntlayer. | - |
getDictionary | Processes dictionary objects and returns content for the current locale. Processes t() translations, enumerations, markdown, HTML, etc. Uses AsyncLocalStorage to access the request context. Can also be accessed via intlayer.getDictionary. | - |
Types
Import:
ts
העתקת קוד
העתקת הקוד ללוח
הצגת כל תוכן הטבלה
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Type | Description |
|---|---|
IntlayerContext | Shape of the intlayer object injected into every route context: locale, locale_storage, locale_detected, defaultLocale, t, getIntlayer, getDictionary. |
TranslateFunction | Signature of the translation function, translating a locale map into the content matching the current request locale. |
Usage
src/index.ts
העתקת קוד
העתקת הקוד ללוח
The plugin registers its context through a globalderive, which Elysia types asPartial<{ intlayer: IntlayerContext }>. The value is always present at runtime for routes registered after.use(intlayer()), so use the non-null assertion (intlayer!.locale), or optional chaining, to satisfy TypeScript instrictmode.
