מחבר:
הפנו את עוזר ה-AI המועדף עליכם למסמך הזהChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Init doc"v9.5.519.9.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתעריכת המסמך הזה
אם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודנוצר:2026-09-19עדכון אחרון:2026-09-19
העתקה
העתקת ה-Markdown של המסמך ללוח
useIntlayer Hook Documentation
The useIntlayer hook allows you to retrieve localized content from an Intlayer dictionary by key in Remix 3 applications.
It automatically reads the active locale from the current request context (via AsyncLocalStorage), so you don't need to pass the locale through route handlers, view templates, or components.
Usage
In Route Handlers
src/server.ts
העתקת קוד
העתקת הקוד ללוח
In View Templates / Components
src/views/home.ts
העתקת קוד
העתקת הקוד ללוח
Parameters
ts
העתקת קוד
העתקת הקוד ללוח
key: The unique key of the dictionary (as defined in your.content.tsdeclaration files).localeOrSelector(optional): A specific locale or selector object ({ item },{ variant }, optionally withlocale). When provided, it overrides the locale detected from the request context.
Description
The hook performs the following tasks:
- Context Locale Retrieval: Detects the current locale from the request-bound
AsyncLocalStoragescope established by theintlayer()middleware. - Dictionary Retrieval: Retrieves the pre-compiled dictionary corresponding to the provided key.
- Translation Processing: Resolves translations, enumerations, markdown, and conditional content for the resolved locale.
- Fallback Handling: If called outside of an active HTTP request context (e.g. background tasks or unit tests without middleware), it gracefully falls back to the configured
defaultLocale.
